File tree Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Expand file tree Collapse file tree 2 files changed +6
-3
lines changed Original file line number Diff line number Diff line change @@ -123,7 +123,11 @@ def func():
123
123
1 / 0
124
124
atexit .register (func )
125
125
try :
126
- atexit ._run_exitfuncs ()
126
+ with support .catch_unraisable_exception () as cm :
127
+ atexit ._run_exitfuncs ()
128
+ self .assertEqual (cm .unraisable .object , func )
129
+ self .assertEqual (cm .unraisable .exc_type , ZeroDivisionError )
130
+ self .assertEqual (type (cm .unraisable .exc_value ), ZeroDivisionError )
127
131
finally :
128
132
atexit .unregister (func )
129
133
Original file line number Diff line number Diff line change @@ -94,8 +94,7 @@ atexit_callfuncs(struct atexit_state *state)
94
94
}
95
95
96
96
// bpo-46025: Increment the refcount of cb->func as the call itself may unregister it
97
- PyObject * the_func = cb -> func ;
98
- Py_INCREF (the_func );
97
+ PyObject * the_func = Py_NewRef (cb -> func );
99
98
PyObject * res = PyObject_Call (cb -> func , cb -> args , cb -> kwargs );
100
99
if (res == NULL ) {
101
100
_PyErr_WriteUnraisableMsg ("in atexit callback" , the_func );
You can’t perform that action at this time.
0 commit comments