]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95808: Add missing early returns in _asynciomodule.c (#95809)
authorYury Selivanov <yury@edgedb.com>
Mon, 15 Aug 2022 23:32:40 +0000 (16:32 -0700)
committerGitHub <noreply@github.com>
Mon, 15 Aug 2022 23:32:40 +0000 (16:32 -0700)
Modules/_asynciomodule.c

index f94819cad24eb2073bc15f3fc13e5e6b25f8a577..9d2f83bf6c73c1a830197586e57a0706e56f1d62 100644 (file)
@@ -631,8 +631,6 @@ create_cancelled_error(FutureObj *fut)
     } else {
         exc = PyObject_CallOneArg(asyncio_CancelledError, msg);
     }
-    PyException_SetContext(exc, fut->fut_cancelled_exc);
-    Py_CLEAR(fut->fut_cancelled_exc);
     return exc;
 }
 
@@ -640,6 +638,9 @@ static void
 future_set_cancelled_error(FutureObj *fut)
 {
     PyObject *exc = create_cancelled_error(fut);
+    if (exc == NULL) {
+        return;
+    }
     PyErr_SetObject(asyncio_CancelledError, exc);
     Py_DECREF(exc);
 }