Skip to content

Commit

Permalink
remove __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
kumaraditya303 authored Sep 17, 2022
1 parent f163b76 commit d7ce7d8
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 89 deletions.
3 changes: 1 addition & 2 deletions Lib/test/test_struct.py
Original file line number Diff line number Diff line change
Expand Up @@ -710,8 +710,7 @@ def test__struct_Struct__new__initialized(self):
@support.cpython_only
def test__struct_Struct_subclassing(self):
class Bob(struct.Struct):
def __init__(self, format):
super().__init__(format)
pass

s = Bob("b")
s.unpack_from(b"abcd")
Expand Down
38 changes: 0 additions & 38 deletions Modules/_struct.c
Original file line number Diff line number Diff line change
Expand Up @@ -1489,43 +1489,6 @@ Struct_impl(PyTypeObject *type, PyObject *format)
return (PyObject *)self;
}

/*[clinic input]
Struct.__init__
format: object
[clinic start generated code]*/

static int
Struct___init___impl(PyStructObject *self, PyObject *format)
/*[clinic end generated code: output=b8e80862444e92d0 input=6c10faf9b8d53954]*/
{
if (PyUnicode_Check(format)) {
format = PyUnicode_AsASCIIString(format);
if (format == NULL) {
return -1;
}
}
else {
Py_INCREF(format);
}

if (!PyBytes_Check(format)) {
Py_DECREF(format);
PyErr_Format(PyExc_TypeError,
"Struct() argument 1 must be a str or bytes object, "
"not %.200s",
_PyType_Name(Py_TYPE(format)));
return -1;
}

Py_SETREF(self->s_format, format);

if (prepare_s(self) < 0) {
return -1;
}
return 0;
}

static int
s_clear(PyStructObject *s)
Expand Down Expand Up @@ -2132,7 +2095,6 @@ static PyType_Slot PyStructType_slots[] = {
{Py_tp_members, s_members},
{Py_tp_getset, s_getsetlist},
{Py_tp_new, Struct},
{Py_tp_init, Struct___init__},
{Py_tp_alloc, PyType_GenericAlloc},
{Py_tp_free, PyObject_GC_Del},
{0, 0},
Expand Down
50 changes: 1 addition & 49 deletions Modules/clinic/_struct.c.h

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit d7ce7d8

Please sign in to comment.