Skip to content

Commit d7ce7d8

Browse files
remove __init__
1 parent f163b76 commit d7ce7d8

File tree

3 files changed

+2
-89
lines changed

3 files changed

+2
-89
lines changed

Lib/test/test_struct.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -710,8 +710,7 @@ def test__struct_Struct__new__initialized(self):
710710
@support.cpython_only
711711
def test__struct_Struct_subclassing(self):
712712
class Bob(struct.Struct):
713-
def __init__(self, format):
714-
super().__init__(format)
713+
pass
715714

716715
s = Bob("b")
717716
s.unpack_from(b"abcd")

Modules/_struct.c

Lines changed: 0 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -1489,43 +1489,6 @@ Struct_impl(PyTypeObject *type, PyObject *format)
14891489
return (PyObject *)self;
14901490
}
14911491

1492-
/*[clinic input]
1493-
Struct.__init__
1494-
1495-
format: object
1496-
1497-
[clinic start generated code]*/
1498-
1499-
static int
1500-
Struct___init___impl(PyStructObject *self, PyObject *format)
1501-
/*[clinic end generated code: output=b8e80862444e92d0 input=6c10faf9b8d53954]*/
1502-
{
1503-
if (PyUnicode_Check(format)) {
1504-
format = PyUnicode_AsASCIIString(format);
1505-
if (format == NULL) {
1506-
return -1;
1507-
}
1508-
}
1509-
else {
1510-
Py_INCREF(format);
1511-
}
1512-
1513-
if (!PyBytes_Check(format)) {
1514-
Py_DECREF(format);
1515-
PyErr_Format(PyExc_TypeError,
1516-
"Struct() argument 1 must be a str or bytes object, "
1517-
"not %.200s",
1518-
_PyType_Name(Py_TYPE(format)));
1519-
return -1;
1520-
}
1521-
1522-
Py_SETREF(self->s_format, format);
1523-
1524-
if (prepare_s(self) < 0) {
1525-
return -1;
1526-
}
1527-
return 0;
1528-
}
15291492

15301493
static int
15311494
s_clear(PyStructObject *s)
@@ -2132,7 +2095,6 @@ static PyType_Slot PyStructType_slots[] = {
21322095
{Py_tp_members, s_members},
21332096
{Py_tp_getset, s_getsetlist},
21342097
{Py_tp_new, Struct},
2135-
{Py_tp_init, Struct___init__},
21362098
{Py_tp_alloc, PyType_GenericAlloc},
21372099
{Py_tp_free, PyObject_GC_Del},
21382100
{0, 0},

Modules/clinic/_struct.c.h

Lines changed: 1 addition & 49 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

0 commit comments

Comments
 (0)