I recently ran some code like this:
with pathlib.Path(encrypted_fpath).open() as encrypted_fo: gpg.decrypt_file(encrypted_fo, always_trust=True, output=target_fpath)
Which hung the process.
I saw this output:
Exception in thread Thread-12: Traceback (most recent call last): File "/opt/python34/lib/python3.4/threading.py", line 920, in _bootstrap_inner self.run() File "/opt/python34/lib/python3.4/threading.py", line 868, in run self._target(*self._args, **self._kwargs) File "/home/rsyring/.virtualenvs/hllapi/lib/python3.4/site-packages/gnupg.py", line 127, in _copy_data data = instream.read(1024) File "/home/rsyring/.virtualenvs/hllapi/lib/python3.4/codecs.py", line 319, in decode (result, consumed) = self._buffer_decode(data, self.errors, final) UnicodeDecodeError: 'utf-8' codec can't decode byte 0x85 in position 0: invalid start byte
I was able to adjust my call to open (
...open('rb')) in order to avoid this exception, but IMO, the main script should also exit with an exception, rather than hanging, if this situation occurs.