@@ -3723,23 +3723,31 @@ typedef struct {
37233723
37243724#define repeatobject_CAST (op ) ((repeatobject *)(op))
37253725
3726+ /*[clinic input]
3727+ @vectorcall
3728+ @classmethod
3729+ itertools.repeat.__new__ as repeat_new
3730+ object as element: object
3731+ times: object(c_default="NULL") = None
3732+ [clinic start generated code]*/
3733+
37263734static PyObject *
3727- repeat_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
3735+ repeat_new_impl (PyTypeObject * type , PyObject * element , PyObject * times )
3736+ /*[clinic end generated code: output=4ef9bd3593335622 input=c0eafe81f60ae9e6]*/
37283737{
37293738 repeatobject * ro ;
3730- PyObject * element ;
3731- Py_ssize_t cnt = -1 , n_args ;
3732- static char * kwargs [] = {"object" , "times" , NULL };
3733-
3734- n_args = PyTuple_GET_SIZE (args );
3735- if (kwds != NULL )
3736- n_args += PyDict_GET_SIZE (kwds );
3737- if (!PyArg_ParseTupleAndKeywords (args , kwds , "O|n:repeat" , kwargs ,
3738- & element , & cnt ))
3739- return NULL ;
3740- /* Does user supply times argument? */
3741- if (n_args == 2 && cnt < 0 )
3742- cnt = 0 ;
3739+ Py_ssize_t cnt = -1 ;
3740+
3741+ if (times != NULL ) {
3742+ /* Does user supply times argument? */
3743+ cnt = PyNumber_AsSsize_t (times , PyExc_OverflowError );
3744+ if (cnt == -1 && PyErr_Occurred ()) {
3745+ return NULL ;
3746+ }
3747+ if (cnt < 0 ) {
3748+ cnt = 0 ;
3749+ }
3750+ }
37433751
37443752 ro = (repeatobject * )type -> tp_alloc (type , 0 );
37453753 if (ro == NULL )
@@ -3830,6 +3838,7 @@ static PyType_Slot repeat_slots[] = {
38303838 {Py_tp_iternext , repeat_next },
38313839 {Py_tp_methods , repeat_methods },
38323840 {Py_tp_new , repeat_new },
3841+ {Py_tp_vectorcall , repeat_vectorcall },
38333842 {Py_tp_free , PyObject_GC_Del },
38343843 {0 , NULL },
38353844};
0 commit comments