Use utf_8 encoding for merge when ascii is configured.
authorZac Medico <zmedico@gentoo.org>
Fri, 2 Sep 2011 02:10:51 +0000 (19:10 -0700)
committerZac Medico <zmedico@gentoo.org>
Fri, 2 Sep 2011 02:10:51 +0000 (19:10 -0700)
It probably won't hurt, and forced conversion to ascii encoding is
known to break some packages that install file names with utf_8
encoding (see bug #381509). The ascii aliases are borrowed from
python's encodings.aliases.aliases dict.

pym/portage/__init__.py

index 72cdf2dbb54a8f3851ee8289d5066acb28410252..901ea2c9678f1bb101030b45a7790c5e582d9772 100644 (file)
@@ -158,9 +158,20 @@ _encodings = {
        'stdio'                  : 'utf_8',
 }
 
-# This can happen if python is built with USE=build (stage 1).
-if _encodings['merge'] is None:
-       _encodings['merge'] = 'ascii'
+# sys.getfilesystemencoding() can return None if python is built with
+# USE=build (stage 1). If the filesystem encoding is undefined or is a
+# subset of utf_8, then we default to utf_8 encoding for merges, since
+# it probably won't hurt, and forced conversion to ascii encoding is
+# known to break some packages that install file names with utf_8
+# encoding (see bug #381509). The ascii aliases are borrowed from
+# python's encodings.aliases.aliases dict.
+if _encodings['merge'] is None or \
+       _encodings['merge'].lower().replace('-', '_') in \
+       ('ascii', '646', 'ansi_x3.4_1968', 'ansi_x3_4_1968',
+       'ansi_x3.4_1986', 'cp367', 'csascii', 'ibm367', 'iso646_us',
+       'iso_646.irv_1991', 'iso_ir_6', 'us', 'us_ascii'):
+
+       _encodings['merge'] = 'utf_8'
 
 if sys.hexversion >= 0x3000000:
        def _unicode_encode(s, encoding=_encodings['content'], errors='backslashreplace'):