File tree Expand file tree Collapse file tree 3 files changed +14
-1
lines changed
Expand file tree Collapse file tree 3 files changed +14
-1
lines changed Original file line number Diff line number Diff line change @@ -23,6 +23,9 @@ def raise1():
2323def raise2 ():
2424 raise SystemError
2525
26+ def exit ():
27+ raise SystemExit
28+
2629
2730class GeneralTest (unittest .TestCase ):
2831
@@ -76,6 +79,13 @@ def test_raise_unnormalized(self):
7679 self .assertRaises (ZeroDivisionError , atexit ._run_exitfuncs )
7780 self .assertIn ("ZeroDivisionError" , self .stream .getvalue ())
7881
82+ def test_exit (self ):
83+ # be sure a SystemExit is handled properly
84+ atexit .register (exit )
85+
86+ self .assertRaises (SystemExit , atexit ._run_exitfuncs )
87+ self .assertEqual (self .stream .getvalue (), '' )
88+
7989 def test_print_tracebacks (self ):
8090 # Issue #18776: the tracebacks should be printed when errors occur.
8191 def f ():
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ Core and Builtins
4949Library
5050-------
5151
52+ - bpo-28994: The traceback no longer displayed for SystemExit raised in
53+ a callback registered by atexit.
54+
5255- bpo-30508: Don't log exceptions if Task/Future "cancel()" method was
5356 called.
5457
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ atexit_callfuncs(void)
9797 Py_XDECREF (exc_tb );
9898 }
9999 PyErr_Fetch (& exc_type , & exc_value , & exc_tb );
100- if (!PyErr_ExceptionMatches ( PyExc_SystemExit )) {
100+ if (!PyErr_GivenExceptionMatches ( exc_type , PyExc_SystemExit )) {
101101 PySys_WriteStderr ("Error in atexit._run_exitfuncs:\n" );
102102 PyErr_NormalizeException (& exc_type , & exc_value , & exc_tb );
103103 PyErr_Display (exc_type , exc_value , exc_tb );
You can’t perform that action at this time.
0 commit comments