diff options
author | Justus Winter <[email protected]> | 2016-07-08 09:45:08 +0000 |
---|---|---|
committer | Justus Winter <[email protected]> | 2016-07-08 09:45:08 +0000 |
commit | 8a93f345b701332270c9829a4d0a93537f98a8d8 (patch) | |
tree | 9a2a18c82f357fbd7c7eba50a5f1204efeeddc63 /lang/python/helpers.c | |
parent | python: Fix distcheck. (diff) | |
download | gpgme-8a93f345b701332270c9829a4d0a93537f98a8d8.tar.gz gpgme-8a93f345b701332270c9829a4d0a93537f98a8d8.zip |
python: Fix raising stashed exceptions.
Fixes an issue with newer versions of Python.
* lang/python/helpers.c (pygpgme_raise_callback_exception): Be more
careful when restoring the exception.
Signed-off-by: Justus Winter <[email protected]>
Diffstat (limited to 'lang/python/helpers.c')
-rw-r--r-- | lang/python/helpers.c | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/lang/python/helpers.c b/lang/python/helpers.c index 1b661466..43a55d08 100644 --- a/lang/python/helpers.c +++ b/lang/python/helpers.c @@ -150,12 +150,18 @@ PyObject *pygpgme_raise_callback_exception(PyObject *self) else Py_INCREF(ptraceback); + /* We now have references for the extracted items. */ Py_DECREF(excinfo); - PyErr_Restore(ptype, pvalue, ptraceback); + /* Clear the exception information. It is important to do this + before setting the error, because setting the attribute may + execute python code, and the runtime system raises a SystemError + if an exception is set but values are returned. */ Py_INCREF(Py_None); PyObject_SetAttrString(self, EXCINFO, Py_None); + /* Restore exception. */ + PyErr_Restore(ptype, pvalue, ptraceback); return NULL; /* Raise exception. */ leave: |