GH-78724: Initialize struct.Struct in __new__ (GH-94532)

Closes https://github.com/python/cpython/issues/75960
Closes https://github.com/python/cpython/issues/78724
This commit is contained in:
Kumar Aditya 2022-09-25 19:02:48 +05:30 committed by GitHub
parent f5f047aa62
commit c8c0afc713
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 49 additions and 41 deletions

View file

@ -8,7 +8,7 @@ preserve
#endif
PyDoc_STRVAR(Struct___init____doc__,
PyDoc_STRVAR(Struct__doc__,
"Struct(format)\n"
"--\n"
"\n"
@ -19,13 +19,13 @@ PyDoc_STRVAR(Struct___init____doc__,
"\n"
"See help(struct) for more on format strings.");
static int
Struct___init___impl(PyStructObject *self, PyObject *format);
static PyObject *
Struct_impl(PyTypeObject *type, PyObject *format);
static int
Struct___init__(PyObject *self, PyObject *args, PyObject *kwargs)
static PyObject *
Struct(PyTypeObject *type, PyObject *args, PyObject *kwargs)
{
int return_value = -1;
PyObject *return_value = NULL;
#if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE)
#define NUM_KEYWORDS 1
@ -61,7 +61,7 @@ Struct___init__(PyObject *self, PyObject *args, PyObject *kwargs)
goto exit;
}
format = fastargs[0];
return_value = Struct___init___impl((PyStructObject *)self, format);
return_value = Struct_impl(type, format);
exit:
return return_value;
@ -451,4 +451,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=eca7df0e75f8919d input=a9049054013a1b77]*/
/*[clinic end generated code: output=f3d6e06f80368998 input=a9049054013a1b77]*/