Skip to content

Commit

Permalink
Replace UnicodeDecodeErrors caused by Python2 readline() method.
Browse files Browse the repository at this point in the history
 * CHANGE gnupg._meta.GPGBase.__init__() to register the builtin
   `codecs.replace_errors` handler and a global codecs "strict" error
   handler.
 * FIXES Issue #49:
   #49
  • Loading branch information
isislovecruft committed Oct 28, 2014
1 parent 79b1cbc commit d9116ba
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions gnupg/_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,6 +159,14 @@ def __init__(self, binary=None, home=None, keyring=None, secring=None,
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')

Expand Down

0 comments on commit d9116ba

Please sign in to comment.