Skip to content

Commit

Permalink
Document the surprising sideeffect PyErr_Print(). (pythonGH-12081)
Browse files Browse the repository at this point in the history
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 <greg@krypto.org>
  • Loading branch information
gpshead authored and miss-islington committed Feb 27, 2019
1 parent 60ef9b0 commit c90e487
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions Doc/c-api/exceptions.rst
Original file line number Diff line number Diff line change
Expand Up @@ -44,8 +44,12 @@ is a separate error indicator for each thread.
.. c:function:: void PyErr_PrintEx(int set_sys_last_vars)
Print a standard traceback to ``sys.stderr`` and clear the error indicator.
Call this function only when the error indicator is set. (Otherwise it will
cause a fatal error!)
**Unless** the error is a ``SystemExit``. In that case the no traceback
is printed and Python process will exit with the error code specified by
the ``SystemExit`` instance.
Call this function **only** when the error indicator is set. Otherwise it
will cause a fatal error!
If *set_sys_last_vars* is nonzero, the variables :data:`sys.last_type`,
:data:`sys.last_value` and :data:`sys.last_traceback` will be set to the
Expand Down

0 comments on commit c90e487

Please sign in to comment.