isislovecruft / python-gnupg

A modified version of python-gnupg, including security patches, extensive documentation, and extra features.
Other
424 stars 172 forks source link

Export with gpg 2.1.11 raises exception because of wrong parser class #151

Closed jantman closed 7 years ago

jantman commented 8 years ago
>>> k = gpg.export_keys(['ee5c1f5b412d53b3'])
Exception in thread Thread-20:
Traceback (most recent call last):
  File "/usr/lib64/python2.7/threading.py", line 801, in __bootstrap_inner
    self.run()
  File "/usr/lib64/python2.7/threading.py", line 754, in run
    self.__target(*self.__args, **self.__kwargs)
  File "/home/jantman/tmp/foo/lib/python2.7/site-packages/gnupg/_meta.py", line 626, in _read_response
    result._handle_status(keyword, value)
  File "/home/jantman/tmp/foo/lib/python2.7/site-packages/gnupg/_parsers.py", line 895, in _handle_status
    raise ValueError("Unknown status message: %r" % key)
ValueError: Unknown status message: u'EXPORTED'

But the returned value is correct.

The problem appears to be in gnupg.py L442:

        p = self._open_subprocess(args)
        ## gpg --export produces no status-fd output; stdout will be empty in
        ## case of failure
        #stdout, stderr = p.communicate()
        result = self._result_map['delete'](self)  # any result will do

However, DeleteResult raises ValueError if the status message is anything other than "DELETE_PROBLEM". It seems that, at least for newer gpg versions, Export should either have its own result parser, or use one that ignores the status.

On a related note, could the documentation say which gpg versions this works with? Or perhaps issue some sort of message when GPG() is instantiated with an unsupported binary?

isislovecruft commented 7 years ago

Fixed in python-gnupg version 2.2.0.