Call PyErr_WriteUnraisable if a destructor sets a Python exception (-builtin)
This fixes the python_destructor_exception testcase for -builtin
This commit is contained in:
parent
a863e98874
commit
e4264e7ba8
1 changed files with 11 additions and 3 deletions
|
|
@ -11,7 +11,15 @@ wrapper##_closure(PyObject *a) { \
|
||||||
sobj = (SwigPyObject *)a; \
|
sobj = (SwigPyObject *)a; \
|
||||||
Py_XDECREF(sobj->dict); \
|
Py_XDECREF(sobj->dict); \
|
||||||
if (sobj->own) { \
|
if (sobj->own) { \
|
||||||
|
PyObject *val = 0, *type = 0, *tb = 0; \
|
||||||
|
PyErr_Fetch(&val, &type, &tb); \
|
||||||
PyObject *o = wrapper(a, NULL); \
|
PyObject *o = wrapper(a, NULL); \
|
||||||
|
if (!o) { \
|
||||||
|
PyObject *deallocname = PyString_FromString(#wrapper); \
|
||||||
|
PyErr_WriteUnraisable(deallocname); \
|
||||||
|
Py_DECREF(deallocname); \
|
||||||
|
} \
|
||||||
|
PyErr_Restore(val, type, tb); \
|
||||||
Py_XDECREF(o); \
|
Py_XDECREF(o); \
|
||||||
} \
|
} \
|
||||||
if (PyType_IS_GC(a->ob_type)) { \
|
if (PyType_IS_GC(a->ob_type)) { \
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue