bpo-1635741: Port _struct to multiphase initialization (GH-23398)

Signed-off-by: Christian Heimes <christian@python.org>
This commit is contained in:
Christian Heimes 2020-11-19 14:36:23 +01:00 committed by GitHub
parent 3390347aa0
commit cfeb5437a8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 272 additions and 239 deletions

View File

@ -0,0 +1 @@
Port _struct extension module to multiphase initialization (:pep:`489`)

File diff suppressed because it is too large Load Diff

View File

@ -199,7 +199,7 @@ calcsize(PyObject *module, PyObject *arg)
PyStructObject *s_object = NULL;
Py_ssize_t _return_value;
if (!cache_struct_converter(arg, &s_object)) {
if (!cache_struct_converter(module, arg, &s_object)) {
goto exit;
}
_return_value = calcsize_impl(module, s_object);
@ -241,7 +241,7 @@ unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("unpack", nargs, 2, 2)) {
goto exit;
}
if (!cache_struct_converter(args[0], &s_object)) {
if (!cache_struct_converter(module, args[0], &s_object)) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
@ -297,7 +297,7 @@ unpack_from(PyObject *module, PyObject *const *args, Py_ssize_t nargs, PyObject
if (!args) {
goto exit;
}
if (!cache_struct_converter(args[0], &s_object)) {
if (!cache_struct_converter(module, args[0], &s_object)) {
goto exit;
}
if (PyObject_GetBuffer(args[1], &buffer, PyBUF_SIMPLE) != 0) {
@ -364,7 +364,7 @@ iter_unpack(PyObject *module, PyObject *const *args, Py_ssize_t nargs)
if (!_PyArg_CheckPositional("iter_unpack", nargs, 2, 2)) {
goto exit;
}
if (!cache_struct_converter(args[0], &s_object)) {
if (!cache_struct_converter(module, args[0], &s_object)) {
goto exit;
}
buffer = args[1];
@ -376,4 +376,4 @@ exit:
return return_value;
}
/*[clinic end generated code: output=8089792d8ed0c1be input=a9049054013a1b77]*/
/*[clinic end generated code: output=a3d3cd900091cb1c input=a9049054013a1b77]*/