* lang/python/src/core.py (Context, Data): Don't call __del__
from __exit__ method, as the object may be still in use.
* lang/python/tests/t-idiomatic.py: Fix the test.
--
GnuPG-bug-id: 6060
Signed-off-by: NIIBE Yutaka <gniibe@fsij.org>
This follows weeks of discussion on the gnupg-devel mailing list.
Hopefully it will make it easier for people using Python to use GnuPG
in the future.
Signed-off-by: Daniel Kahn Gillmor <dkg@fifthhorseman.net>
* lang/python/helpers.c (pyDataWriteCb): Handle Python integers being
returned on Python 2.
(pyDataSeekCb): Likewise.
* lang/python/pyme/core.py (Data.__init__): Fix testing for string
argument.
(Data.new_from_filepart): Likewise.
* lang/python/pyme/util.py (is_a_string): New function.
* lang/python/tests/t-encrypt-large.py (read_cb): Force evaluation of
generator.
* lang/python/tests/t-idiomatic.py: Partly skip test on Python 2.
* lang/python/tests/t-verify.py (check_result): Here, the difference
between 2 and 3 really matters. We cannot change the char *
conversion in Python 2 without breaking all existing applications, and
using bytestrings in Python 3 would be very inconvenient.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/Makefile.am: Add the toplevel source directory to CFLAGS
when compiling the bindings so that we can use private header files.
* lang/python/gpgme.i (gpgme_data_t): Rework the object wrapping. Do
not create a Python wrapper object, merely a gpgme_data_t object, and
keep references to buffer objects, if any. If necessary, update the
buffer after the function call.
(pygpgme_wrap_gpgme_data_t): New function.
* lang/python/helpers.c (object_to_gpgme_data_t): Rework object
wrapping. Also wrap objects implementing the buffer protocol.
* lang/python/helpers.h (object_to_gpgme_data_t): Update prototype.
(pygpgme_wrap_gpgme_data_t): New prototype.
* lang/python/tests/t-idiomatic.py: Demonstrate this.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/pyme/core.py (Context.__del__): Make function
idemptotent.
(Context.{__enter__,__exit__}): Implement the context manager
protocol.
(Data.__del__): Make function idemptotent, drop debug print.
(Data.{__enter__,__exit__}): Implement the context manager
protocol.
* lang/python/tests/t-idiomatic.py: Demonstrate this.
Signed-off-by: Justus Winter <justus@g10code.com>
* lang/python/gpgme.i (gpgme_data_t): Use new function to create
wrapper objects if necessary, and deallocate them after the function
call.
* lang/python/helpers.c (object_to_gpgme_data_t): New function.
* lang/python/helpers.h (object_to_gpgme_data_t): New prototype.
* lang/python/tests/Makefile.am (pytests): Add new test.
* lang/python/tests/t-idiomatic.py: New file.
Signed-off-by: Justus Winter <justus@g10code.com>