diff options
author | Zac Medico <zmedico@gentoo.org> | 2010-01-13 04:12:56 +0000 |
---|---|---|
committer | Zac Medico <zmedico@gentoo.org> | 2010-01-13 04:12:56 +0000 |
commit | c693312f55cf05074746e39939edd80562353c70 (patch) | |
tree | 024d01042d645b4ddfdd6b158b40a8c99677cbbd | |
parent | 58159e43cd60cfcd78d1084df0ff37423a379ba6 (diff) | |
download | portage-c693312f55cf05074746e39939edd80562353c70.tar.gz portage-c693312f55cf05074746e39939edd80562353c70.tar.bz2 portage-c693312f55cf05074746e39939edd80562353c70.zip |
Use encoded byte strings with python-2.x, since the python ebuilds are
known to remove the encodings module when USE=build is enabled (thus
disabling unicode decoding/encoding).
svn path=/main/trunk/; revision=15197
-rwxr-xr-x | bin/check-implicit-pointer-usage.py | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py index 1f6417b58..8822c4504 100755 --- a/bin/check-implicit-pointer-usage.py +++ b/bin/check-implicit-pointer-usage.py @@ -34,29 +34,33 @@ pointer_pattern = ( + "cast to pointer from integer of different size)") 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 + # Use encoded byte strings in python-2.x, since the python ebuilds are + # known to remove the encodings module when USE=build is enabled (thus + # disabling unicode decoding/encoding). The portage module has a + # workaround for this, but currently we don't import that here since we + # don't want to trigger potential sandbox violations due to stale pyc + # files for the portage module. + unicode_quote_open = '\xE2\x80\x98' + unicode_quote_close = '\xE2\x80\x99' + def write(msg): + sys.stdout.write(msg) else: unicode_quote_open = '\u2018' unicode_quote_close = '\u2019' - out = sys.stdout.buffer + def write(msg): + sys.stdout.buffer.write(msg.encode('utf_8', 'backslashreplace')) + 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') else: - line = unicode(sys.stdin.readline(), - encoding='utf_8', errors='replace') + line = sys.stdin.readline() if not line: break # translate unicode open/close quotes to ascii ones |