diff --git a/Documentation/replace_macros.py b/Documentation/replace_macros.py index 2996a98aea..c76d133936 100755 --- a/Documentation/replace_macros.py +++ b/Documentation/replace_macros.py @@ -1,4 +1,4 @@ -#!/usr/bin/env python2 +#!/usr/bin/env python # coding=utf-8 # Copyright (C) 2013 The Android Open Source Project # @@ -229,12 +229,16 @@ opts.add_option('--no-searchbox', action="store_false", dest='searchbox', options, _ = opts.parse_args() try: - out_file = open(options.out, 'w') - src_file = open(options.src, 'r') + try: + out_file = open(options.out, 'w', errors='ignore') + src_file = open(options.src, 'r', errors='ignore') + except TypeError: + out_file = open(options.out, 'w') + src_file = open(options.src, 'r') last_line = '' ignore_next_line = False last_title = '' - for line in src_file.xreadlines(): + for line in src_file: if PAT_GERRIT.match(last_line): # Case of "GERRIT\n------" at the footer out_file.write(GERRIT_UPLINK) diff --git a/tools/bzl/license-map.py b/tools/bzl/license-map.py index 1c8db72ef5..74a84cc3e4 100644 --- a/tools/bzl/license-map.py +++ b/tools/bzl/license-map.py @@ -113,8 +113,13 @@ for n in sorted(graph.keys()): print() print("[[%s_license]]" % safename) print("----") - with open(n[2:].replace(":", "/")) as fd: - copyfileobj(fd, stdout) + filename = n[2:].replace(":", "/") + try: + with open(filename, errors='ignore') as fd: + copyfileobj(fd, stdout) + except TypeError: + with open(filename) as fd: + copyfileobj(fd, stdout) print() print("----") print() diff --git a/tools/bzl/license.bzl b/tools/bzl/license.bzl index 357817303a..38dfbe5e28 100644 --- a/tools/bzl/license.bzl +++ b/tools/bzl/license.bzl @@ -25,7 +25,7 @@ def license_map(name, targets = [], opts = [], **kwargs): # post process the XML into our favorite format. native.genrule( name = "gen_license_txt_" + name, - cmd = "python2 $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)), + cmd = "python $(location //tools/bzl:license-map.py) %s %s > $@" % (" ".join(opts), " ".join(xmls)), outs = [ name + ".txt" ], tools = tools, **kwargs