diff options
author | dol-sen <brian.dolbec@gmail.com> | 2011-08-09 18:04:21 -0700 |
---|---|---|
committer | dol-sen <brian.dolbec@gmail.com> | 2011-08-09 18:04:21 -0700 |
commit | ee2ba4c60fb555f406b23aa3daf1c8fe5f35022d (patch) | |
tree | a871cca51d9f5bb5513c2765291433d6b0b65114 | |
parent | revert using "as" in exceptions. enable using the "with" statement in py-2.5. (diff) | |
download | layman-ee2ba4c60fb555f406b23aa3daf1c8fe5f35022d.tar.gz layman-ee2ba4c60fb555f406b23aa3daf1c8fe5f35022d.tar.bz2 layman-ee2ba4c60fb555f406b23aa3daf1c8fe5f35022d.zip |
add the gentoolkit encoding bugfix
-rw-r--r-- | layman/utils.py | 11 |
1 files changed, 10 insertions, 1 deletions
diff --git a/layman/utils.py b/layman/utils.py index eedc5d7..6f144be 100644 --- a/layman/utils.py +++ b/layman/utils.py @@ -64,7 +64,16 @@ def get_encoding(output): and output.encoding != None: return output.encoding else: - return locale.getpreferredencoding() + 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' + return encoding def pad(string, length): |