@@ -1913,28 +1913,22 @@ chain_new_internal(PyTypeObject *type, PyObject *source)
19131913 return (PyObject * )lz ;
19141914}
19151915
1916- /*[clinic input]
1917- @vectorcall
1918- @classmethod
1919- itertools.chain.__new__ as chain_new
1920- *iterables: array
1921- [clinic start generated code]*/
1922-
19231916static PyObject *
1924- chain_new_impl (PyTypeObject * type , PyObject * const * iterables ,
1925- Py_ssize_t iterables_length )
1926- /*[clinic end generated code: output=ca3d5f6d6ddedec4 input=0346ceca117a3021]*/
1917+ chain_new (PyTypeObject * type , PyObject * args , PyObject * kwds )
19271918{
1928- PyObject * source = PyTuple_FromArray (iterables , iterables_length );
1929- if (source == NULL ) {
1919+ PyObject * source ;
1920+
1921+ itertools_state * state = find_state_by_type (type );
1922+ PyTypeObject * chain_type = state -> chain_type ;
1923+ if ((type == chain_type || type -> tp_init == chain_type -> tp_init ) &&
1924+ !_PyArg_NoKeywords ("chain" , kwds ))
19301925 return NULL ;
1931- }
1932- PyObject * it = PyObject_GetIter (source );
1933- Py_DECREF (source );
1934- if (it == NULL ) {
1926+
1927+ source = PyObject_GetIter (args );
1928+ if (source == NULL )
19351929 return NULL ;
1936- }
1937- return chain_new_internal (type , it );
1930+
1931+ return chain_new_internal (type , source );
19381932}
19391933
19401934/*[clinic input]
@@ -2054,7 +2048,6 @@ static PyType_Slot chain_slots[] = {
20542048 {Py_tp_iternext , chain_next },
20552049 {Py_tp_methods , chain_methods },
20562050 {Py_tp_new , chain_new },
2057- {Py_tp_vectorcall , chain_vectorcall },
20582051 {Py_tp_free , PyObject_GC_Del },
20592052 {0 , NULL },
20602053};
0 commit comments