From 666eb414ebc4d852410699f061c4b2d505f59308 Mon Sep 17 00:00:00 2001 From: Ivan Alejandro Date: Mon, 11 Nov 2013 16:24:28 -0300 Subject: Use 'utf-8' as default/fallback encoding. - Also reorder stdlib imports alphabetically :) --- src/leap/keymanager/openpgp.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) (limited to 'src') 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): -- cgit v1.2.3