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 <justus@g10code.com>
This commit is contained in:
parent
52efcf1ee9
commit
8a93f345b7
@ -150,12 +150,18 @@ PyObject *pygpgme_raise_callback_exception(PyObject *self)
|
|||||||
else
|
else
|
||||||
Py_INCREF(ptraceback);
|
Py_INCREF(ptraceback);
|
||||||
|
|
||||||
|
/* We now have references for the extracted items. */
|
||||||
Py_DECREF(excinfo);
|
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);
|
Py_INCREF(Py_None);
|
||||||
PyObject_SetAttrString(self, EXCINFO, Py_None);
|
PyObject_SetAttrString(self, EXCINFO, Py_None);
|
||||||
|
|
||||||
|
/* Restore exception. */
|
||||||
|
PyErr_Restore(ptype, pvalue, ptraceback);
|
||||||
return NULL; /* Raise exception. */
|
return NULL; /* Raise exception. */
|
||||||
|
|
||||||
leave:
|
leave:
|
||||||
|
Loading…
Reference in New Issue
Block a user