Gentoo Archives: gentoo-commits

From: "Zac Medico (zmedico)" <zmedico@g.o>
To: gentoo-commits@l.g.o
Subject: [gentoo-commits] portage r15251 - main/branches/2.1.7/bin
Date: Fri, 29 Jan 2010 18:48:44
Message-Id: E1NavtY-0006to-Ig@stork.gentoo.org
1 Author: zmedico
2 Date: 2010-01-29 18:48:40 +0000 (Fri, 29 Jan 2010)
3 New Revision: 15251
4
5 Modified:
6 main/branches/2.1.7/bin/check-implicit-pointer-usage.py
7 Log:
8 Use encoded byte strings with python-2.x, since the python ebuilds are
9 known to remove the encodings module when USE=build is enabled (thus
10 disabling unicode decoding/encoding). (trunk r15197)
11
12 Modified: main/branches/2.1.7/bin/check-implicit-pointer-usage.py
13 ===================================================================
14 --- main/branches/2.1.7/bin/check-implicit-pointer-usage.py 2010-01-29 18:48:32 UTC (rev 15250)
15 +++ main/branches/2.1.7/bin/check-implicit-pointer-usage.py 2010-01-29 18:48:40 UTC (rev 15251)
16 @@ -34,29 +34,33 @@
17 + "cast to pointer from integer of different size)")
18
19 if sys.hexversion < 0x3000000:
20 - pointer_pattern = unicode(pointer_pattern, encoding='utf_8')
21 - unicode_quote_open = unicode('\xE2\x80\x98', encoding='utf_8')
22 - unicode_quote_close = unicode('\xE2\x80\x99', encoding='utf_8')
23 - out = sys.stdout
24 + # Use encoded byte strings in python-2.x, since the python ebuilds are
25 + # known to remove the encodings module when USE=build is enabled (thus
26 + # disabling unicode decoding/encoding). The portage module has a
27 + # workaround for this, but currently we don't import that here since we
28 + # don't want to trigger potential sandbox violations due to stale pyc
29 + # files for the portage module.
30 + unicode_quote_open = '\xE2\x80\x98'
31 + unicode_quote_close = '\xE2\x80\x99'
32 + def write(msg):
33 + sys.stdout.write(msg)
34 else:
35 unicode_quote_open = '\u2018'
36 unicode_quote_close = '\u2019'
37 - out = sys.stdout.buffer
38 + def write(msg):
39 + sys.stdout.buffer.write(msg.encode('utf_8', 'backslashreplace'))
40 +
41 pointer_pattern = re.compile(pointer_pattern)
42
43 last_implicit_filename = ""
44 last_implicit_linenum = -1
45 last_implicit_func = ""
46
47 -def write(msg):
48 - out.write(msg.encode('utf_8', 'backslashreplace'))
49 -
50 while True:
51 if sys.hexversion >= 0x3000000:
52 line = sys.stdin.buffer.readline().decode('utf_8', 'replace')
53 else:
54 - line = unicode(sys.stdin.readline(),
55 - encoding='utf_8', errors='replace')
56 + line = sys.stdin.readline()
57 if not line:
58 break
59 # translate unicode open/close quotes to ascii ones