From: Zac Medico Date: Fri, 29 Jan 2010 18:47:59 +0000 (-0000) Subject: Avoid potential UnicodeDecodeError with Python 3. Reported by devurandom. X-Git-Tag: v2.1.7.17~25 X-Git-Url: http://git.tremily.us/gitweb.cgi?a=commitdiff_plain;h=c22b577e59b3100751c4ecd40e71e218e8a31407;p=portage.git Avoid potential UnicodeDecodeError with Python 3. Reported by devurandom. (trunk r15192) svn path=/main/branches/2.1.7/; revision=15247 --- diff --git a/bin/check-implicit-pointer-usage.py b/bin/check-implicit-pointer-usage.py index 100c4a4b1..e9790c850 100755 --- a/bin/check-implicit-pointer-usage.py +++ b/bin/check-implicit-pointer-usage.py @@ -19,6 +19,8 @@ from __future__ import print_function import re import sys +from portage import _unicode_decode + implicit_pattern = re.compile("([^:]*):(\d+): warning: implicit declaration " + "of function [`']([^']*)'") pointer_pattern = re.compile( @@ -37,7 +39,10 @@ last_implicit_linenum = -1 last_implicit_func = "" while True: - line = sys.stdin.readline() + if sys.hexversion >= 0x3000000: + line = _unicode_decode(sys.stdin.buffer.readline()) + else: + line = sys.stdin.readline() if line == '': break # translate unicode open/close quotes to ascii ones