diff options
author | Tomás Touceda <chiiph@leap.se> | 2013-11-11 16:36:26 -0300 |
---|---|---|
committer | Tomás Touceda <chiiph@leap.se> | 2013-11-11 16:36:26 -0300 |
commit | 4daab9b4bb279679611c1e4ec51c08f5987be27c (patch) | |
tree | f92e498643123fb84aeec3ed48cd3a0ca0c5026e | |
parent | e021b4236ffce9dfb6e302971e8d2f460b601bf3 (diff) | |
parent | 666eb414ebc4d852410699f061c4b2d505f59308 (diff) |
Merge remote-tracking branch 'ivan/bug/4427_default-encoding-to-utf8' into develop
-rw-r--r-- | changes/bug-4427_default-encoding-to-utf8 | 2 | ||||
-rw-r--r-- | src/leap/keymanager/openpgp.py | 8 |
2 files changed, 9 insertions, 1 deletions
diff --git a/changes/bug-4427_default-encoding-to-utf8 b/changes/bug-4427_default-encoding-to-utf8 new file mode 100644 index 00000000..3f7d6713 --- /dev/null +++ b/changes/bug-4427_default-encoding-to-utf8 @@ -0,0 +1,2 @@ + o Default encoding to 'utf-8' in case of system encodings not set. Closes + #4427. diff --git a/src/leap/keymanager/openpgp.py b/src/leap/keymanager/openpgp.py index a4dc1b8b..1670e1c9 100644 --- a/src/leap/keymanager/openpgp.py +++ b/src/leap/keymanager/openpgp.py @@ -21,12 +21,14 @@ Infrastructure for using OpenPGP keys in Key Manager. """ +import locale import logging import os import re import shutil +import sys import tempfile -import locale + from contextlib import closing from gnupg import GPG @@ -516,6 +518,10 @@ class OpenPGPScheme(EncryptionScheme): # https://github.com/isislovecruft/python-gnupg/\ # blob/master/gnupg/_meta.py#L121 encoding = locale.getpreferredencoding() + if encoding is None: + encoding = sys.stdin.encoding + if encoding is None: + encoding = 'utf-8' return result.data.decode(encoding, 'replace') def is_encrypted(self, data): |