]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Document the surprising sideeffect PyErr_Print(). (#12081)
authorGregory P. Smith <greg@krypto.org>
Wed, 27 Feb 2019 23:27:32 +0000 (15:27 -0800)
committerGitHub <noreply@github.com>
Wed, 27 Feb 2019 23:27:32 +0000 (15:27 -0800)
Did you know an API documented as printing the pending traceback would sometimes exit the process?

You do now.

Doc/c-api/exceptions.rst

index 6dd0c02c6d7bacf23dbd85c767c23fb50583fb95..8c5f66cbef722b4e9565f489f0c83d1dba29c612 100644 (file)
@@ -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