From 09803c4a81b9431fd4c8f30abb1c60c4c735f0cb Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Tue, 24 May 2016 12:29:32 +0200 Subject: python: Improve support for edit callbacks. * lang/python/helpers.c (pyEditCb): Stash exceptions. * lang/python/pyme/core.py (Context.op_edit): Hand in 'self'. * lang/python/tests/Makefile.am (py_tests): Add new test. * lang/python/tests/t-callbacks.py: Test edit callbacks. * lang/python/tests/t-edit.py: New file. Signed-off-by: Justus Winter --- lang/python/pyme/core.py | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) (limited to 'lang/python/pyme/core.py') diff --git a/lang/python/pyme/core.py b/lang/python/pyme/core.py index 9e7faf77..1b4e6ae0 100644 --- a/lang/python/pyme/core.py +++ b/lang/python/pyme/core.py @@ -225,8 +225,15 @@ class Context(GpgmeWrapper): """Start key editing using supplied callback function""" if key == None: raise ValueError("op_edit: First argument cannot be None") - opaquedata = (func, fnc_value) - errorcheck(pygpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out)) + if fnc_value: + opaquedata = (self, func, fnc_value) + else: + opaquedata = (self, func) + + result = pygpgme.gpgme_op_edit(self.wrapped, key, opaquedata, out) + if self._callback_excinfo: + pygpgme.pygpgme_raise_callback_exception(self) + errorcheck(result) class Data(GpgmeWrapper): """From the GPGME C manual: -- cgit v1.2.3