We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 76d14fa commit 05fbd60Copy full SHA for 05fbd60
Modules/_asynciomodule.c
@@ -1371,10 +1371,15 @@ _asyncio_Future__make_cancelled_error_impl(FutureObj *self)
1371
{
1372
PyObject *exc = create_cancelled_error(self->fut_cancel_msg);
1373
_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;
+
+ if (exc_state->exc_value) {
+ PyException_SetContext(exc, Py_NewRef(exc_state->exc_value));
+ _PyErr_ClearExcState(exc_state);
1378
+ }
1379
+ else {
1380
+ assert(exc_state->exc_type == NULL);
1381
+ assert(exc_state->exc_traceback == NULL);
1382
1383
1384
return exc;
1385
}
0 commit comments