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():
23
23
def raise2 ():
24
24
raise SystemError
25
25
26
+ def exit ():
27
+ raise SystemExit
28
+
26
29
27
30
class GeneralTest (unittest .TestCase ):
28
31
@@ -76,6 +79,13 @@ def test_raise_unnormalized(self):
76
79
self .assertRaises (ZeroDivisionError , atexit ._run_exitfuncs )
77
80
self .assertIn ("ZeroDivisionError" , self .stream .getvalue ())
78
81
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
+
79
89
def test_print_tracebacks (self ):
80
90
# Issue #18776: the tracebacks should be printed when errors occur.
81
91
def f ():
Original file line number Diff line number Diff line change @@ -49,6 +49,9 @@ Core and Builtins
49
49
Library
50
50
-------
51
51
52
+ - bpo-28994: The traceback no longer displayed for SystemExit raised in
53
+ a callback registered by atexit.
54
+
52
55
- bpo-30508: Don't log exceptions if Task/Future "cancel()" method was
53
56
called.
54
57
Original file line number Diff line number Diff line change @@ -97,7 +97,7 @@ atexit_callfuncs(void)
97
97
Py_XDECREF (exc_tb );
98
98
}
99
99
PyErr_Fetch (& exc_type , & exc_value , & exc_tb );
100
- if (!PyErr_ExceptionMatches ( PyExc_SystemExit )) {
100
+ if (!PyErr_GivenExceptionMatches ( exc_type , PyExc_SystemExit )) {
101
101
PySys_WriteStderr ("Error in atexit._run_exitfuncs:\n" );
102
102
PyErr_NormalizeException (& exc_type , & exc_value , & exc_tb );
103
103
PyErr_Display (exc_type , exc_value , exc_tb );
You can’t perform that action at this time.
0 commit comments