]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
bpo-47057: Use FASTCALL convention for FutureIter.throw() (GH-31973)
authorAndrew Svetlov <andrew.svetlov@gmail.com>
Sat, 19 Mar 2022 12:01:46 +0000 (14:01 +0200)
committerGitHub <noreply@github.com>
Sat, 19 Mar 2022 12:01:46 +0000 (14:01 +0200)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Misc/NEWS.d/next/Library/2022-03-18-14-22-38.bpo-47057.n-IHbt.rst [new file with mode: 0644]
Modules/_asynciomodule.c

diff --git a/Misc/NEWS.d/next/Library/2022-03-18-14-22-38.bpo-47057.n-IHbt.rst b/Misc/NEWS.d/next/Library/2022-03-18-14-22-38.bpo-47057.n-IHbt.rst
new file mode 100644 (file)
index 0000000..b404b45
--- /dev/null
@@ -0,0 +1 @@
+Use FASTCALL convention for ``FutureIter.throw()``
index 24119782d9c4d59ca6cce9863f280dbf4fe5febd..c3e9cb2fa2a3039149a75b1240a131030a2c109c 100644 (file)
@@ -1637,18 +1637,23 @@ FutureIter_send(futureiterobject *self, PyObject *unused)
 }
 
 static PyObject *
-FutureIter_throw(futureiterobject *self, PyObject *args)
+FutureIter_throw(futureiterobject *self, PyObject *const *args, Py_ssize_t nargs)
 {
     PyObject *type, *val = NULL, *tb = NULL;
-    if (!PyArg_ParseTuple(args, "O|OO", &type, &val, &tb))
+    if (!_PyArg_CheckPositional("throw", nargs, 1, 3)) {
         return NULL;
+    }
 
-    if (val == Py_None) {
-        val = NULL;
+    type = args[0];
+    if (nargs == 3) {
+        val = args[1];
+        tb = args[2];
+    }
+    else if (nargs == 2) {
+        val = args[1];
     }
-    if (tb == Py_None) {
-        tb = NULL;
-    } else if (tb != NULL && !PyTraceBack_Check(tb)) {
+
+    if (tb != NULL && !PyTraceBack_Check(tb)) {
         PyErr_SetString(PyExc_TypeError, "throw() third argument must be a traceback");
         return NULL;
     }
@@ -1708,7 +1713,7 @@ FutureIter_traverse(futureiterobject *it, visitproc visit, void *arg)
 
 static PyMethodDef FutureIter_methods[] = {
     {"send",  (PyCFunction)FutureIter_send, METH_O, NULL},
-    {"throw", (PyCFunction)FutureIter_throw, METH_VARARGS, NULL},
+    {"throw", (PyCFunction)(void(*)(void))FutureIter_throw, METH_FASTCALL, NULL},
     {"close", (PyCFunction)FutureIter_close, METH_NOARGS, NULL},
     {NULL, NULL}        /* Sentinel */
 };