Handing a reference to the wrapper object created a non-trivial
circular reference that Pythons garbage collector is unable to break.
Explicitly break it by using a weak reference.
* lang/python/helpers.c (pygpgme_stash_callback_exception): Retrieve
object from weak reference.
* lang/python/pyme/core.py (Context.__del__): Free status callback.
(Context.set_passphrase_cb): Use a weak reference.
(Context.set_progress_cb): Likewise.
(Context.set_status_cb): Likewise.
(Context.op_edit): Likewise.
Signed-off-by: Justus Winter <justus@gnupg.org>
* lang/python/pyme/core.py (Data.__init__): Add 'copy' kwargument, and
pass it to functions supporting it. PEP8 fix.
(Data.new_from_fd): PEP8 fix.
(Data.new_from_file): Give a more helpful error message if copy is
False. PEP8 fix.
(Data.new_from_fd): Hand the file descriptor to
'gpgme_data_new_from_fd', not a stream. Fix docstring.
* lang/python/tests/t-data.py: Add tests for this.
Signed-off-by: Justus Winter <justus@gnupg.org>
* lang/python/pyme/core.py (Context.wait): Improve docstring. As the
context passed to 'gpgme_wait' is never NULL, it is pointless to look
at the returned context. Always raise exceptions.
* lang/python/tests/Makefile.am (pytests): Add new test.
* lang/python/tests/t-wait.py: New file.
Signed-off-by: Justus Winter <justus@gnupg.org>
* lang/python/pyme/core.py: Avoid races at interpreter shutdown. This
silences the most annoying occurrences, however this problem also
affects the SWIG generated code, which might indicate that the real
problem is somewhere else. If so, this change can be easily reverted.
Signed-off-by: Justus Winter <justus@gnupg.org>
* lang/python/gpgme.i: Adjust to Python3's string type being
'Unicode', not 'bytes'. Fix type checking.
* lang/python/core.py (Data.write): Add docstring mentioning the
expected type of parameter 'buffer'.
(Data.read): Adjust read loop. Also, use a saner chunk size, and join
all chunks at the end instead of adding them.
* lang/python/examples/simple.py: Adjust example.
Signed-off-by: Justus Winter <justus@gnupg.org>