File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -1371,10 +1371,15 @@ _asyncio_Future__make_cancelled_error_impl(FutureObj *self)
13711371{
13721372 PyObject * exc = create_cancelled_error (self -> fut_cancel_msg );
13731373 _PyErr_StackItem * exc_state = & self -> fut_cancelled_exc_state ;
1374- /* Transfer ownership of exc_value from exc_state to exc since we are
1375- done with it. */
1376- PyException_SetContext (exc , exc_state -> exc_value );
1377- exc_state -> exc_value = NULL ;
1374+
1375+ if (exc_state -> exc_value ) {
1376+ PyException_SetContext (exc , Py_NewRef (exc_state -> exc_value ));
1377+ _PyErr_ClearExcState (exc_state );
1378+ }
1379+ else {
1380+ assert (exc_state -> exc_type == NULL );
1381+ assert (exc_state -> exc_traceback == NULL );
1382+ }
13781383
13791384 return exc ;
13801385}
You can’t perform that action at this time.
0 commit comments