Skip to content

Commit a588343

Browse files
Document the surprising sideeffect PyErr_Print(). (GH-12081)
Did you know an API documented as printing the pending traceback would sometimes exit the process? You do now. (cherry picked from commit 4173772) Co-authored-by: Gregory P. Smith <[email protected]>
1 parent 60ef9b0 commit a588343

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
@@ -44,8 +44,12 @@ is a separate error indicator for each thread.
4444
.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
4545
4646
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
47-
Call this function only when the error indicator is set. (Otherwise it will
48-
cause a fatal error!)
47+
**Unless** the error is a ``SystemExit``. In that case the no traceback
48+
is printed and Python process will exit with the error code specified by
49+
the ``SystemExit`` instance.
50+
51+
Call this function **only** when the error indicator is set. Otherwise it
52+
will cause a fatal error!
4953
5054
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
5155
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the

0 commit comments

Comments
 (0)