[New-bugs-announce] [issue36951] Wrong types for PyMemberDefs in Objects/typeobject.c
Kevin Shweh
report at bugs.python.org
Fri May 17 15:50:54 EDT 2019
New submission from Kevin Shweh <kevin.shweh at gmail.com>:
In Objects/typeobject.c, the PyMemberDefs for __flags__, __weakrefoffset__, and __dictoffset__ all use T_LONG:
{"__flags__", T_LONG, offsetof(PyTypeObject, tp_flags), READONLY},
{"__weakrefoffset__", T_LONG,
offsetof(PyTypeObject, tp_weaklistoffset), READONLY},
...
{"__dictoffset__", T_LONG,
offsetof(PyTypeObject, tp_dictoffset), READONLY},
{"__weakrefoffset__", T_LONG,
offsetof(PyTypeObject, tp_weaklistoffset), READONLY},
but in Include/object.h or Include/cpython/object.h, the corresponding struct members have types unsigned long, Py_ssize_t, and Py_ssize_t respectively:
/* Flags to define presence of optional/expanded features */
unsigned long tp_flags;
...
/* weak reference enabler */
Py_ssize_t tp_weaklistoffset;
...
Py_ssize_t tp_dictoffset;
These uses of T_LONG should be changed to T_ULONG and T_PYSSIZE_T.
This was checked on 3.7.3 and master.
----------
components: Interpreter Core
messages: 342759
nosy: Kevin Shweh
priority: normal
severity: normal
status: open
title: Wrong types for PyMemberDefs in Objects/typeobject.c
type: behavior
versions: Python 3.7, Python 3.8
_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue36951>
_______________________________________
More information about the New-bugs-announce
mailing list