From 82562066096bcb3fa57656775aa79bad69bceada Mon Sep 17 00:00:00 2001 From: Zac Medico Date: Thu, 1 Sep 2011 19:10:51 -0700 Subject: [PATCH] Use utf_8 encoding for merge when ascii is configured. 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 | 17 ++++++++++++++--- 1 file changed, 14 insertions(+), 3 deletions(-) diff --git a/pym/portage/__init__.py b/pym/portage/__init__.py index 72cdf2dbb..901ea2c96 100644 --- a/pym/portage/__init__.py +++ b/pym/portage/__init__.py @@ -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'): -- 2.26.2