Skip to content

Commit af3e491

Browse files
miss-islington1st1
andauthored
gh-95808: Add missing early returns in _asynciomodule.c (GH-95809)
(cherry picked from commit b2afe48) Co-authored-by: Yury Selivanov <[email protected]>
1 parent d55a775 commit af3e491

File tree

1 file changed

+3
-2
lines changed

1 file changed

+3
-2
lines changed

Modules/_asynciomodule.c

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -631,15 +631,16 @@ create_cancelled_error(FutureObj *fut)
631631
} else {
632632
exc = PyObject_CallOneArg(asyncio_CancelledError, msg);
633633
}
634-
PyException_SetContext(exc, fut->fut_cancelled_exc);
635-
Py_CLEAR(fut->fut_cancelled_exc);
636634
return exc;
637635
}
638636

639637
static void
640638
future_set_cancelled_error(FutureObj *fut)
641639
{
642640
PyObject *exc = create_cancelled_error(fut);
641+
if (exc == NULL) {
642+
return;
643+
}
643644
PyErr_SetObject(asyncio_CancelledError, exc);
644645
Py_DECREF(exc);
645646
}

0 commit comments

Comments
 (0)