diff options
author | Mark Dickinson <dickinsm@gmail.com> | 2023-11-26 14:29:52 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-11-26 14:29:52 (GMT) |
commit | 9fe60340d7e8dc22b3aec205c557bc69a1b2d18c (patch) | |
tree | 9047eeb509b3a097caf58d9168ac719454cbb1fe /Modules/clinic | |
parent | 3faf8e586d36e73faba13d9b61663afed6a24cb4 (diff) | |
download | cpython-9fe60340d7e8dc22b3aec205c557bc69a1b2d18c.zip cpython-9fe60340d7e8dc22b3aec205c557bc69a1b2d18c.tar.gz cpython-9fe60340d7e8dc22b3aec205c557bc69a1b2d18c.tar.bz2 |
gh-112358: Fix Python 3.12 regression with subclassing struct.Struct. (#112424)
Revert commit c8c0afc7137ab9f22bf59d591084948ca967c97c (PR #94532),
which moved `struct.Struct` initialisation from `Struct.__init__` to `Struct.__new__`.
This caused issues with code in the wild that subclasses `struct.Struct`.
Diffstat (limited to 'Modules/clinic')
-rw-r--r-- | Modules/clinic/_struct.c.h | 16 |
1 files changed, 8 insertions, 8 deletions
diff --git a/Modules/clinic/_struct.c.h b/Modules/clinic/_struct.c.h index e5118fb..1a07532 100644 --- a/Modules/clinic/_struct.c.h +++ b/Modules/clinic/_struct.c.h @@ -9,7 +9,7 @@ preserve #include "pycore_abstract.h" // _PyNumber_Index() #include "pycore_modsupport.h" // _PyArg_UnpackKeywords() -PyDoc_STRVAR(Struct__doc__, +PyDoc_STRVAR(Struct___init____doc__, "Struct(format)\n" "--\n" "\n" @@ -20,13 +20,13 @@ PyDoc_STRVAR(Struct__doc__, "\n" "See help(struct) for more on format strings."); -static PyObject * -Struct_impl(PyTypeObject *type, PyObject *format); +static int +Struct___init___impl(PyStructObject *self, PyObject *format); -static PyObject * -Struct(PyTypeObject *type, PyObject *args, PyObject *kwargs) +static int +Struct___init__(PyObject *self, PyObject *args, PyObject *kwargs) { - PyObject *return_value = NULL; + int return_value = -1; #if defined(Py_BUILD_CORE) && !defined(Py_BUILD_CORE_MODULE) #define NUM_KEYWORDS 1 @@ -62,7 +62,7 @@ Struct(PyTypeObject *type, PyObject *args, PyObject *kwargs) goto exit; } format = fastargs[0]; - return_value = Struct_impl(type, format); + return_value = Struct___init___impl((PyStructObject *)self, format); exit: return return_value; @@ -436,4 +436,4 @@ exit: return return_value; } -/*[clinic end generated code: output=6a20e87f9b298b14 input=a9049054013a1b77]*/ +/*[clinic end generated code: output=67bd299e5d72fee0 input=a9049054013a1b77]*/ |