Skip to content

Commit 4173772

Browse files
authored
Document the surprising sideeffect PyErr_Print(). (#12081)
Did you know an API documented as printing the pending traceback would sometimes exit the process? You do now.
1 parent 4064089 commit 4173772

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

Doc/c-api/exceptions.rst

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,12 @@ Printing and clearing
5353
.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
5454
5555
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
56-
Call this function only when the error indicator is set. (Otherwise it will
57-
cause a fatal error!)
56+
**Unless** the error is a ``SystemExit``. In that case the no traceback
57+
is printed and Python process will exit with the error code specified by
58+
the ``SystemExit`` instance.
59+
60+
Call this function **only** when the error indicator is set. Otherwise it
61+
will cause a fatal error!
5862
5963
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
6064
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the

0 commit comments

Comments
 (0)