summaryrefslogtreecommitdiffstats
path: root/Python/Python-ast.c
diff options
context:
space:
mode:
authorPetr Viktorin <encukou@gmail.com>2024-03-20 16:33:08 (GMT)
committerGitHub <noreply@github.com>2024-03-20 16:33:08 (GMT)
commitdcaf33a41d5d220523d71c9b35bc08f5b8405dac (patch)
tree495bf3368e58d9fef72317a883d96cf81228c169 /Python/Python-ast.c
parent44fbab43d8f3f2df07091d237824cf4fa1f6c57c (diff)
downloadcpython-dcaf33a41d5d220523d71c9b35bc08f5b8405dac.zip
cpython-dcaf33a41d5d220523d71c9b35bc08f5b8405dac.tar.gz
cpython-dcaf33a41d5d220523d71c9b35bc08f5b8405dac.tar.bz2
gh-114314: ctypes: remove stgdict and switch to heap types (GH-116458)
Before this change, ctypes classes used a custom dict subclass, `StgDict`, as their `tp_dict`. This acts like a regular dict but also includes extra information about the type. This replaces stgdict by `StgInfo`, a C struct on the type, accessed by `PyObject_GetTypeData()` (PEP-697). All usage of `StgDict` (mainly variables named `stgdict`, `dict`, `edict` etc.) is converted to `StgInfo` (named `stginfo`, `info`, `einfo`, etc.). Where the dict is actually used for class attributes (as a regular PyDict), it's now called `attrdict`. This change -- not overriding `tp_dict` -- is made to make me comfortable with the next part of this PR: moving the initialization logic from `tp_new` to `tp_init`. The `StgInfo` is set up in `__init__` of each class, with a guard that prevents calling `__init__` more than once. Note that abstract classes (like `Array` or `Structure`) are created using `PyType_FromMetaclass` and do not have `__init__` called. Previously, this was done in `__new__`, which also wasn't called for abstract classes. Since `__init__` can be called from Python code or skipped, there is a tested guard to ensure `StgInfo` is initialized exactly once before it's used. Co-authored-by: neonene <53406459+neonene@users.noreply.github.com> Co-authored-by: Erlend E. Aasland <erlend.aasland@protonmail.com>
Diffstat (limited to 'Python/Python-ast.c')
0 files changed, 0 insertions, 0 deletions