[Python-checkins] Document the surprising sideeffect PyErr_Print(). (GH-12081)

Miss Islington (bot) webhook-mailer at python.org
Wed Feb 27 18:45:31 EST 2019


https://github.com/python/cpython/commit/661151b3417a30912024dc72854286f1db4fe72b
commit: 661151b3417a30912024dc72854286f1db4fe72b
branch: 3.7
author: Miss Islington (bot) <31488909+miss-islington at users.noreply.github.com>
committer: GitHub <noreply at github.com>
date: 2019-02-27T15:45:28-08:00
summary:

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 4173772031747a9b249be4100b4aa9eda805ea23)

Co-authored-by: Gregory P. Smith <greg at krypto.org>

files:
M Doc/c-api/exceptions.rst

diff --git a/Doc/c-api/exceptions.rst b/Doc/c-api/exceptions.rst
index dd1e026cb071..cd06096ef7bb 100644
--- a/Doc/c-api/exceptions.rst
+++ b/Doc/c-api/exceptions.rst
@@ -53,8 +53,12 @@ Printing and clearing
 .. 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



More information about the Python-checkins mailing list