Skip to content

Commit 1189097

Browse files
committed
Add back in example
1 parent a9f1ee1 commit 1189097

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

Doc/c-api/typeobj.rst

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)