Avoid potential UnicodeDecodeError with Python 3. Reported by devurandom.
authorArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 11 Jan 2010 19:16:19 +0000 (19:16 -0000)
committerArfrever Frehtes Taifersar Arahesis <arfrever@gentoo.org>
Mon, 11 Jan 2010 19:16:19 +0000 (19:16 -0000)
svn path=/main/trunk/; revision=15192

bin/check-implicit-pointer-usage.py

index 100c4a4b16f38a7831a6b60d34ac2f14bbe6672f..e9790c850a644415869f0451b35712291533d0c0 100755 (executable)
@@ -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