This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Wrong types for PyMemberDefs in Objects/typeobject.c
Type: behavior Stage: resolved
Components: Interpreter Core Versions: Python 3.8, Python 3.7, Python 2.7
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Kevin Shweh, ZackerySpytz, benjamin.peterson, miss-islington
Priority: normal Keywords: patch

Created on 2019-05-17 19:50 by Kevin Shweh, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 13403 merged ZackerySpytz, 2019-05-18 06:57
PR 13433 merged miss-islington, 2019-05-20 00:26
PR 13434 merged miss-islington, 2019-05-20 00:26
Messages (6)
msg342759 - (view) Author: Kevin Shweh (Kevin Shweh) Date: 2019-05-17 19:50
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.
msg342760 - (view) Author: Kevin Shweh (Kevin Shweh) Date: 2019-05-17 19:54
Looks like I accidentally doubled the PyMemberDef for __weakrefoffset__ while editing. There's no double definition in the actual file.
msg342788 - (view) Author: Zackery Spytz (ZackerySpytz) * (Python triager) Date: 2019-05-18 07:02
I agree that this should be fixed.
msg342882 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2019-05-20 00:26
New changeset 53d378c81286644138415cb56da52a7351e1a477 by Benjamin Peterson (Zackery Spytz) in branch 'master':
closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
https://github.com/python/cpython/commit/53d378c81286644138415cb56da52a7351e1a477
msg342883 - (view) Author: miss-islington (miss-islington) Date: 2019-05-20 00:49
New changeset eda691dd9d076e175c396dc6f85dee2795572f6c by Miss Islington (bot) in branch '2.7':
closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
https://github.com/python/cpython/commit/eda691dd9d076e175c396dc6f85dee2795572f6c
msg342884 - (view) Author: miss-islington (miss-islington) Date: 2019-05-20 00:54
New changeset 64b0bdba7ee30ecc5c4c5ad46fb6afd6c0ddd487 by Miss Islington (bot) in branch '3.7':
closes bpo-36951: Correct some types in the type_members struct in typeobject.c. (GH-13403)
https://github.com/python/cpython/commit/64b0bdba7ee30ecc5c4c5ad46fb6afd6c0ddd487
History
Date User Action Args
2022-04-11 14:59:15adminsetgithub: 81132
2019-05-20 00:54:12miss-islingtonsetmessages: + msg342884
2019-05-20 00:49:55miss-islingtonsetnosy: + miss-islington
messages: + msg342883
2019-05-20 00:26:56miss-islingtonsetpull_requests: + pull_request13344
2019-05-20 00:26:46miss-islingtonsetpull_requests: + pull_request13343
2019-05-20 00:26:38benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg342882

resolution: fixed
stage: patch review -> resolved
2019-05-18 07:02:01ZackerySpytzsetnosy: + ZackerySpytz

messages: + msg342788
versions: + Python 2.7
2019-05-18 06:57:37ZackerySpytzsetkeywords: + patch
stage: patch review
pull_requests: + pull_request13315
2019-05-17 19:54:47Kevin Shwehsetmessages: + msg342760
2019-05-17 19:50:54Kevin Shwehcreate