]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-95808: Add missing early returns in _asynciomodule.c (GH-95809)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Tue, 16 Aug 2022 09:52:10 +0000 (02:52 -0700)
committerGitHub <noreply@github.com>
Tue, 16 Aug 2022 09:52:10 +0000 (02:52 -0700)
(cherry picked from commit b2afe482f21b826d53886a69ea2c99d0d940c59a)

Co-authored-by: Yury Selivanov <yury@edgedb.com>
Modules/_asynciomodule.c

index cb7afecd8f2cdf80445be1f3aab7312bd1127e98..10679be2ef19382c47a737a257e80862375d8482 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);
 }