]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-111789: Use PyDict_GetItemRef() in Modules/_asynciomodule.c (GH-112072)
authorSerhiy Storchaka <storchaka@gmail.com>
Wed, 15 Nov 2023 04:28:30 +0000 (06:28 +0200)
committerGitHub <noreply@github.com>
Wed, 15 Nov 2023 04:28:30 +0000 (04:28 +0000)
Modules/_asynciomodule.c

index 6d06208dd1d70d4ac253cf500bdeb95096f3248e..3a11cdc926f13805d2be013c9b3f6738ab549146 100644 (file)
@@ -3514,15 +3514,11 @@ _asyncio_current_task_impl(PyObject *module, PyObject *loop)
         Py_INCREF(loop);
     }
 
-    ret = PyDict_GetItemWithError(state->current_tasks, loop);
+    int rc = PyDict_GetItemRef(state->current_tasks, loop, &ret);
     Py_DECREF(loop);
-    if (ret == NULL && PyErr_Occurred()) {
-        return NULL;
-    }
-    else if (ret == NULL) {
+    if (rc == 0) {
         Py_RETURN_NONE;
     }
-    Py_INCREF(ret);
     return ret;
 }