Skip to content

Commit c21f828

Browse files
authored
pythongh-104276: Make _struct.unpack_iterator type use type flag instead of custom constructor (python#104277)
1 parent 85f9818 commit c21f828

File tree

1 file changed

+1
-7
lines changed

1 file changed

+1
-7
lines changed

Modules/_struct.c

+1-7
Original file line numberDiff line numberDiff line change
@@ -1832,19 +1832,13 @@ unpackiter_iternext(unpackiterobject *self)
18321832
return result;
18331833
}
18341834

1835-
PyObject *unpackiter_new(PyTypeObject *type, PyObject *args, PyObject *kwds) {
1836-
PyErr_Format(PyExc_TypeError, "Cannot create '%.200s objects", _PyType_Name(type));
1837-
return NULL;
1838-
}
1839-
18401835
static PyType_Slot unpackiter_type_slots[] = {
18411836
{Py_tp_dealloc, unpackiter_dealloc},
18421837
{Py_tp_getattro, PyObject_GenericGetAttr},
18431838
{Py_tp_traverse, unpackiter_traverse},
18441839
{Py_tp_iter, PyObject_SelfIter},
18451840
{Py_tp_iternext, unpackiter_iternext},
18461841
{Py_tp_methods, unpackiter_methods},
1847-
{Py_tp_new, unpackiter_new},
18481842
{0, 0},
18491843
};
18501844

@@ -1853,7 +1847,7 @@ static PyType_Spec unpackiter_type_spec = {
18531847
sizeof(unpackiterobject),
18541848
0,
18551849
(Py_TPFLAGS_DEFAULT | Py_TPFLAGS_HAVE_GC |
1856-
Py_TPFLAGS_IMMUTABLETYPE),
1850+
Py_TPFLAGS_IMMUTABLETYPE | Py_TPFLAGS_DISALLOW_INSTANTIATION),
18571851
unpackiter_type_slots
18581852
};
18591853

0 commit comments

Comments
 (0)