File tree Expand file tree Collapse file tree 1 file changed +14
-1
lines changed
Expand file tree Collapse file tree 1 file changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -2149,7 +2149,20 @@ and :c:data:`PyType_Type` effectively act as defaults.)
21492149 that it finds the object in a sane state.
21502150
21512151 :c:member: `~PyTypeObject.tp_finalize ` should not mutate the current exception
2152- status. Non-trivial finalizers should use :c:func: `PyErr_GetRaisedException `.
2152+ status. Non-trivial finalizers should use :c:func: `PyErr_GetRaisedException `,
2153+ an example::
2154+
2155+ static void
2156+ local_finalize(PyObject *self)
2157+ {
2158+ /* Save the current exception, if any. */
2159+ PyObject *exc = PyErr_GetRaisedException();
2160+
2161+ /* ... */
2162+
2163+ /* Restore the saved exception. */
2164+ PyErr_SetRaisedException(exc);
2165+ }
21532166
21542167 **Inheritance: **
21552168
You can’t perform that action at this time.
0 commit comments