Replace UnicodeDecodeErrors caused by Python2 readline() method.
* CHANGE gnupg._meta.GPGBase.__init__() to register the builtin `codecs.replace_errors` handler and a global codecs "strict" error handler. * FIXES Issue #49: https://github.com/isislovecruft/python-gnupg/issues/49fix/49-unicode-decode-on-readline
parent
79b1cbc260
commit
d9116bace6
|
@ -159,6 +159,14 @@ class GPGBase(object):
|
|||
self._filesystemencoding = encodings.normalize_encoding(
|
||||
sys.getfilesystemencoding().lower())
|
||||
|
||||
# Issue #49: https://github.com/isislovecruft/python-gnupg/issues/49
|
||||
#
|
||||
# During `line = stream.readline()` in `_read_response()`, the Python
|
||||
# codecs module will choke on Unicode data, so we globally monkeypatch
|
||||
# the "strict" error handler to use the builtin `replace_errors`
|
||||
# handler:
|
||||
codecs.register_error('strict', codecs.replace_errors)
|
||||
|
||||
self._keyserver = 'hkp://wwwkeys.pgp.net'
|
||||
self.__generated_keys = os.path.join(self.homedir, 'generated-keys')
|
||||
|
||||
|
|
Loading…
Reference in New Issue