@@ -1637,18 +1637,23 @@ FutureIter_send(futureiterobject *self, PyObject *unused)
16371637}
16381638
16391639static PyObject *
1640- FutureIter_throw (futureiterobject * self , PyObject * args )
1640+ FutureIter_throw (futureiterobject * self , PyObject * const * args , Py_ssize_t nargs )
16411641{
16421642 PyObject * type , * val = NULL , * tb = NULL ;
1643- if (!PyArg_ParseTuple ( args , "O|OO " , & type , & val , & tb ))
1643+ if (!_PyArg_CheckPositional ( "throw " , nargs , 1 , 3 )) {
16441644 return NULL ;
1645+ }
16451646
1646- if (val == Py_None ) {
1647- val = NULL ;
1647+ type = args [0 ];
1648+ if (nargs == 3 ) {
1649+ val = args [1 ];
1650+ tb = args [2 ];
1651+ }
1652+ else if (nargs == 2 ) {
1653+ val = args [1 ];
16481654 }
1649- if (tb == Py_None ) {
1650- tb = NULL ;
1651- } else if (tb != NULL && !PyTraceBack_Check (tb )) {
1655+
1656+ if (tb != NULL && !PyTraceBack_Check (tb )) {
16521657 PyErr_SetString (PyExc_TypeError , "throw() third argument must be a traceback" );
16531658 return NULL ;
16541659 }
@@ -1708,7 +1713,7 @@ FutureIter_traverse(futureiterobject *it, visitproc visit, void *arg)
17081713
17091714static PyMethodDef FutureIter_methods [] = {
17101715 {"send" , (PyCFunction )FutureIter_send , METH_O , NULL },
1711- {"throw" , (PyCFunction )FutureIter_throw , METH_VARARGS , NULL },
1716+ {"throw" , (PyCFunction )( void ( * )( void )) FutureIter_throw , METH_FASTCALL , NULL },
17121717 {"close" , (PyCFunction )FutureIter_close , METH_NOARGS , NULL },
17131718 {NULL , NULL } /* Sentinel */
17141719};
0 commit comments