summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAndrew Svetlov <andrew.svetlov@gmail.com>2022-03-19 12:01:46 (GMT)
committerGitHub <noreply@github.com>2022-03-19 12:01:46 (GMT)
commit0a8b8e0d262eae83ffbc6b414a1f5747cdbd1d88 (patch)
tree1996154054c82e6c2f3d2b0bdfbb4893cbe7f7a4 /Modules
parent77473846439b8a3eae66de1a1cfe931619f38513 (diff)
downloadcpython-0a8b8e0d262eae83ffbc6b414a1f5747cdbd1d88.zip
cpython-0a8b8e0d262eae83ffbc6b414a1f5747cdbd1d88.tar.gz
cpython-0a8b8e0d262eae83ffbc6b414a1f5747cdbd1d88.tar.bz2
bpo-47057: Use FASTCALL convention for FutureIter.throw() (GH-31973)
Co-authored-by: Kumar Aditya <59607654+kumaraditya303@users.noreply.github.com>
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_asynciomodule.c21
1 files changed, 13 insertions, 8 deletions
diff --git a/Modules/_asynciomodule.c b/Modules/_asynciomodule.c
index 2411978..c3e9cb2 100644
--- a/Modules/_asynciomodule.c
+++ b/Modules/_asynciomodule.c
@@ -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 */
};