diff options
author | Stephan Bergmann <sbergman@redhat.com> | 2020-05-11 22:46:12 +0200 |
---|---|---|
committer | Stephan Bergmann <sbergman@redhat.com> | 2020-05-12 08:24:16 +0200 |
commit | 23d9966751566028c50ca95ca203d20f36c64f30 (patch) | |
tree | 74c94755ce3550c31e00da24c4d96b492102b19b /test | |
parent | 1861aaaa4ea5c899f8c01691562e5cad5be9b884 (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 'test')
0 files changed, 0 insertions, 0 deletions