mirror of
https://github.com/python/cpython.git
synced 2025-11-02 11:08:57 +00:00
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
This commit is contained in:
parent
5bcf33de0b
commit
3597c12941
3 changed files with 192 additions and 91 deletions
|
|
@ -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;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue