Fix initialization of Python-3.8--only at-end tp_print member
Until Python 3.7, PyTypeObject had a member tp_print following tp_dealloc, which
had then been repurposed as
> /* Methods to implement standard operations */
>
> destructor tp_dealloc;
> - printfunc tp_print;
> + Py_ssize_t tp_vectorcall_offset;
> getattrfunc tp_getattr;
> setattrfunc tp_setattr;
> PyAsyncMethods *tp_as_async; /* formerly known as tp_compare (Python 2)
in <https://github.com/python/cpython/commit/
aacc77fbd77640a8f03638216fa09372cc21673d> "bpo-36974: implement PEP 590
(GH-13185)" towards Python 3.8. Then only on the 3.8 branch (and prior to tag
v3.8.0), <https://github.com/python/cpython/commit/
d917cfe4051d45b2b755c726c096ecfcc4869ceb> "[3.8] bpo-37250: put back tp_print
for backwards compatibility (GH-14193)" added
> destructor tp_finalize;
> vectorcallfunc tp_vectorcall;
>
> + /* bpo-37250: kept for backwards compatibility in CPython 3.8 only */
> + Py_DEPRECATED(3.8) int (*tp_print)(PyObject *, FILE *, int);
> +
> #ifdef COUNT_ALLOCS
> /* these must be last and never explicitly initialized */
> Py_ssize_t tp_allocs;
at the end of PyTypeObject. This was apparently done so that third-party code
containing initialization code like
X.tp_print = 0;
would continue to compile (by just adding back a member with that name, even if
at a "random" new---and otherwise unused---location). However, for our way of
list-initializing PyTypeObject instances in pyuno that new member caused
"missing field 'tp_print' initializer" -Wmissing-field-initializers warnings, so
50ccb7e82b
"python 3.8.2 compile: add tp_print to
PyTypeObject" added initializers for this new at-end member. But it did so in a
way that raises three concerns:
1 The new member was already added in Python 3.8.0 (prior to tag v3.8.0), not
only in 3.8.2.
2 The new member was only added to Python 3.8. It has not been added to
current master towards 3.9.
3 It is unclear why the comments mention "Py_ssize_t" as the type of that new
member, when actually it is of a function pointer type (see above). Probably
best to just drop that from the comments, to avoid confusion.
Change-Id: Ib44f43befd5f28d4c1ac1e9e14bd55bfb4473507
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94019
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
This commit is contained in:
@@ -1660,12 +1660,12 @@ static PyTypeObject PyUNOType =
|
||||
, nullptr
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
, nullptr // vectorcallfunc tp_vectorcall
|
||||
#if PY_VERSION_HEX >= 0x03080200
|
||||
#if PY_VERSION_HEX < 0x03090000
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
, nullptr //Py_ssize_t tp_print
|
||||
, nullptr // tp_print
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
@@ -235,12 +235,12 @@ static PyTypeObject PyUNO_callable_Type =
|
||||
, nullptr
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
, nullptr // vectorcallfunc tp_vectorcall
|
||||
#if PY_VERSION_HEX >= 0x03080200
|
||||
#if PY_VERSION_HEX < 0x03090000
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
, nullptr //Py_ssize_t tp_print
|
||||
, nullptr // tp_print
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
@@ -167,12 +167,12 @@ static PyTypeObject PyUNO_iterator_Type =
|
||||
, nullptr
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
, nullptr // vectorcallfunc tp_vectorcall
|
||||
#if PY_VERSION_HEX >= 0x03080200
|
||||
#if PY_VERSION_HEX < 0x03090000
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
, nullptr //Py_ssize_t tp_print
|
||||
, nullptr // tp_print
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
@@ -313,12 +313,12 @@ static PyTypeObject PyUNO_list_iterator_Type =
|
||||
, nullptr
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
, nullptr // vectorcallfunc tp_vectorcall
|
||||
#if PY_VERSION_HEX >= 0x03080200
|
||||
#if PY_VERSION_HEX < 0x03090000
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
, nullptr //Py_ssize_t tp_print
|
||||
, nullptr // tp_print
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
@@ -127,12 +127,12 @@ static PyTypeObject RuntimeImpl_Type =
|
||||
, nullptr
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
, nullptr // vectorcallfunc tp_vectorcall
|
||||
#if PY_VERSION_HEX >= 0x03080200
|
||||
#if PY_VERSION_HEX < 0x03090000
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
, nullptr //Py_ssize_t tp_print
|
||||
, nullptr // tp_print
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
@@ -347,12 +347,12 @@ static PyTypeObject PyUNOStructType =
|
||||
, nullptr
|
||||
#if PY_VERSION_HEX >= 0x03080000
|
||||
, nullptr // vectorcallfunc tp_vectorcall
|
||||
#if PY_VERSION_HEX >= 0x03080200
|
||||
#if PY_VERSION_HEX < 0x03090000
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic push
|
||||
#pragma clang diagnostic ignored "-Wdeprecated-declarations"
|
||||
#endif
|
||||
, nullptr //Py_ssize_t tp_print
|
||||
, nullptr // tp_print
|
||||
#if defined __clang__
|
||||
#pragma clang diagnostic pop
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user