diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-01-29 18:48:32 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-01-29 18:48:32 +0000 |
commit | 0f85c5c360f2f9f32614a5e47da27666dd1e12a1 (patch) | |
tree | fcfd8abb69c4485804c0aa7c2458d9039d2b8182 /bin | |
parent | eb245d02d14b851f38d700f63665f4e0024737c0 (diff) | |
download | portage-0f85c5c360f2f9f32614a5e47da27666dd1e12a1.tar.gz portage-0f85c5c360f2f9f32614a5e47da27666dd1e12a1.tar.bz2 portage-0f85c5c360f2f9f32614a5e47da27666dd1e12a1.zip |
Fix output handling to avoid potential UnicodeEncodeError. (trunk r15196)
svn path=/main/branches/2.1.7/; revision=15250
Diffstat (limited to 'bin')
-rwxr-xr-x | bin/check-implicit-pointer-usage.py | 12 |
1 files changed, 9 insertions, 3 deletions
diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py index ebd4c3629..1f6417b58 100755 --- a/bin/check-implicit-pointer-usage.py +++ b/bin/check-implicit-pointer-usage.py @@ -37,15 +37,20 @@ if sys.hexversion < 0x3000000: pointer_pattern = unicode(pointer_pattern, encoding='utf_8') unicode_quote_open = unicode('\xE2\x80\x98', encoding='utf_8') unicode_quote_close = unicode('\xE2\x80\x99', encoding='utf_8') + out = sys.stdout else: unicode_quote_open = '\u2018' unicode_quote_close = '\u2019' + out = sys.stdout.buffer pointer_pattern = re.compile(pointer_pattern) last_implicit_filename = "" last_implicit_linenum = -1 last_implicit_func = "" +def write(msg): + out.write(msg.encode('utf_8', 'backslashreplace')) + while True: if sys.hexversion >= 0x3000000: line = sys.stdin.buffer.readline().decode('utf_8', 'replace') @@ -69,6 +74,7 @@ while True: pointer_linenum = int(m.group(2)) if (last_implicit_filename == pointer_filename and last_implicit_linenum == pointer_linenum): - print(("Function `%s' implicitly converted to pointer at " \ - "%s:%d" % (last_implicit_func, last_implicit_filename, - last_implicit_linenum))) + write("Function `%s' implicitly converted to pointer at " \ + "%s:%d\n" % (last_implicit_func, + last_implicit_filename, + last_implicit_linenum)) |