diff options
author | Petr Viktorin <encukou@gmail.com> | 2022-06-14 09:13:29 (GMT) |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-06-14 09:13:29 (GMT) |
commit | 3597c129413a86f805beca78b7c72a20b5bf801c (patch) | |
tree | f02588dbe3d96dcb1e8adf30083c385609836033 /Modules | |
parent | 5bcf33de0b6729bbd4ced442f69c55ff99ea4be0 (diff) | |
download | cpython-3597c129413a86f805beca78b7c72a20b5bf801c.zip cpython-3597c129413a86f805beca78b7c72a20b5bf801c.tar.gz cpython-3597c129413a86f805beca78b7c72a20b5bf801c.tar.bz2 |
gh-89546: Clean up PyType_FromMetaclass (GH-93686)
When changing PyType_FromMetaclass recently (GH-93012, GH-93466, GH-28748)
I found a bunch of opportunities to improve the code. Here they are.
Fixes: #89546
Automerge-Triggered-By: GH:encukou
Diffstat (limited to 'Modules')
-rw-r--r-- | Modules/_testcapimodule.c | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index 33dc3db..54957db 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -1221,7 +1221,7 @@ static PyType_Spec MinimalMetaclass_spec = { static PyType_Spec MinimalType_spec = { .name = "_testcapi.MinimalSpecType", - .basicsize = sizeof(PyObject), + .basicsize = 0, // Updated later .flags = Py_TPFLAGS_DEFAULT, .slots = empty_type_slots, }; @@ -1245,6 +1245,7 @@ test_from_spec_metatype_inheritance(PyObject *self, PyObject *Py_UNUSED(ignored) goto finally; } + MinimalType_spec.basicsize = (int)(((PyTypeObject*)class)->tp_basicsize); new = PyType_FromSpecWithBases(&MinimalType_spec, class); if (new == NULL) { goto finally; |