From d90857a08c4fe5b73b6d6d46fd6200efdd72db44 Mon Sep 17 00:00:00 2001 From: Justus Winter Date: Thu, 19 May 2016 11:03:27 +0200 Subject: python: Robust exception handling in callbacks. * lang/python/helpers.c (pygpgme_stash_callback_exception): New function. (pygpgme_raise_callback_exception): Likewise. (pyPassphraseCb): Stash python errors. * lang/python/helpers.h (pygpgme_raise_callback_exception): New prototype. * lang/python/pyme/core.py ({Context,Data}.__init__): Move common initialization to superclass. (Context.set_progress_cb): Hand in 'self'. * lang/python/pyme/util.py (GpgmeWrapper.__init__): New function. (GpgmeWrapper.__getattr__): Raise stashed exceptions. * lang/python/tests/Makefile.am (py_tests): Add new test. * lang/python/tests/t-callbacks.py: New file. Signed-off-by: Justus Winter --- lang/python/helpers.h | 1 + 1 file changed, 1 insertion(+) (limited to 'lang/python/helpers.h') diff --git a/lang/python/helpers.h b/lang/python/helpers.h index 12d7cfa2..81d17ffa 100644 --- a/lang/python/helpers.h +++ b/lang/python/helpers.h @@ -30,6 +30,7 @@ void pygpgme_exception_init(void); gpgme_error_t pygpgme_exception2code(void); void pygpgme_clear_generic_cb(PyObject **cb); +PyObject *pygpgme_raise_callback_exception(PyObject *self); void pygpgme_set_passphrase_cb(gpgme_ctx_t ctx, PyObject *cb, PyObject **freelater); -- cgit v1.2.3