summaryrefslogtreecommitdiff
path: root/pyuno/source/module/pyuno_struct.cxx
diff options
context:
space:
mode:
authorStephan Bergmann <sbergman@redhat.com>2020-05-11 22:46:12 +0200
committerStephan Bergmann <sbergman@redhat.com>2020-05-12 08:24:16 +0200
commit23d9966751566028c50ca95ca203d20f36c64f30 (patch)
tree74c94755ce3550c31e00da24c4d96b492102b19b /pyuno/source/module/pyuno_struct.cxx
parent1861aaaa4ea5c899f8c01691562e5cad5be9b884 (diff)
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 50ccb7e82b7053306721cbe220323be072306a29 "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>
Diffstat (limited to 'pyuno/source/module/pyuno_struct.cxx')
-rw-r--r--pyuno/source/module/pyuno_struct.cxx4
1 files changed, 2 insertions, 2 deletions
diff --git a/pyuno/source/module/pyuno_struct.cxx b/pyuno/source/module/pyuno_struct.cxx
index 7696a231f24a..a5b127dc23c6 100644
--- a/pyuno/source/module/pyuno_struct.cxx
+++ b/pyuno/source/module/pyuno_struct.cxx
@@ -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