locale.getpreferredencoding() is unknown to python. (Bug 350156)
import sys
import locale
+import codecs
import portage.output as output
from portage import archlist
file = getattr(file, 'buffer', file)
encoding = locale.getpreferredencoding()
+ # Make sure that python knows the encoding. Bug 350156
+ try:
+ # We don't care about what is returned, we just want to
+ # verify that we can find a codec.
+ codecs.lookup(encoding)
+ except LookupError:
+ # Python does not know the encoding, so use utf-8.
+ encoding = 'utf_8'
def encoded_args():
for arg in args: