1 |
commit: 82562066096bcb3fa57656775aa79bad69bceada |
2 |
Author: Zac Medico <zmedico <AT> gentoo <DOT> org> |
3 |
AuthorDate: Fri Sep 2 02:10:51 2011 +0000 |
4 |
Commit: Zac Medico <zmedico <AT> gentoo <DOT> org> |
5 |
CommitDate: Fri Sep 2 02:10:51 2011 +0000 |
6 |
URL: http://git.overlays.gentoo.org/gitweb/?p=proj/portage.git;a=commit;h=82562066 |
7 |
|
8 |
Use utf_8 encoding for merge when ascii is configured. |
9 |
|
10 |
It probably won't hurt, and forced conversion to ascii encoding is |
11 |
known to break some packages that install file names with utf_8 |
12 |
encoding (see bug #381509). The ascii aliases are borrowed from |
13 |
python's encodings.aliases.aliases dict. |
14 |
|
15 |
--- |
16 |
pym/portage/__init__.py | 17 ++++++++++++++--- |
17 |
1 files changed, 14 insertions(+), 3 deletions(-) |
18 |
|
19 |
diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py |
20 |
index 72cdf2d..901ea2c 100644 |
21 |
--- a/pym/portage/__init__.py |
22 |
+++ b/pym/portage/__init__.py |
23 |
@@ -158,9 +158,20 @@ _encodings = { |
24 |
'stdio' : 'utf_8', |
25 |
} |
26 |
|
27 |
-# This can happen if python is built with USE=build (stage 1). |
28 |
-if _encodings['merge'] is None: |
29 |
- _encodings['merge'] = 'ascii' |
30 |
+# sys.getfilesystemencoding() can return None if python is built with |
31 |
+# USE=build (stage 1). If the filesystem encoding is undefined or is a |
32 |
+# subset of utf_8, then we default to utf_8 encoding for merges, since |
33 |
+# it probably won't hurt, and forced conversion to ascii encoding is |
34 |
+# known to break some packages that install file names with utf_8 |
35 |
+# encoding (see bug #381509). The ascii aliases are borrowed from |
36 |
+# python's encodings.aliases.aliases dict. |
37 |
+if _encodings['merge'] is None or \ |
38 |
+ _encodings['merge'].lower().replace('-', '_') in \ |
39 |
+ ('ascii', '646', 'ansi_x3.4_1968', 'ansi_x3_4_1968', |
40 |
+ 'ansi_x3.4_1986', 'cp367', 'csascii', 'ibm367', 'iso646_us', |
41 |
+ 'iso_646.irv_1991', 'iso_ir_6', 'us', 'us_ascii'): |
42 |
+ |
43 |
+ _encodings['merge'] = 'utf_8' |
44 |
|
45 |
if sys.hexversion >= 0x3000000: |
46 |
def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'): |