diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2015-01-28 08:52:49 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2015-01-28 08:52:49 (GMT) |
commit | 4c54387f11d8c38d3bf59f547ab72b78354ad5de (patch) | |
tree | efedf4c583d8404bcd09ad45ccc4496134814d96 /Objects | |
parent | 9e74fc3ee2d3bb2a37bd79855dce78191a00142e (diff) | |
download | cpython-4c54387f11d8c38d3bf59f547ab72b78354ad5de.zip cpython-4c54387f11d8c38d3bf59f547ab72b78354ad5de.tar.gz cpython-4c54387f11d8c38d3bf59f547ab72b78354ad5de.tar.bz2 |
Issue #22079: PyType_Ready() now checks that statically allocated type has
no dynamically allocated bases.
Diffstat (limited to 'Objects')
-rw-r--r-- | Objects/typeobject.c | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 619ac9b..23dda2a 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -4073,6 +4073,20 @@ PyType_Ready(PyTypeObject *type) inherit_slots(type, (PyTypeObject *)b); } + /* All bases of statically allocated type should be statically allocated */ + if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) + for (i = 0; i < n; i++) { + PyObject *b = PyTuple_GET_ITEM(bases, i); + if (PyType_Check(b) && + (((PyTypeObject *)b)->tp_flags & Py_TPFLAGS_HEAPTYPE)) { + PyErr_Format(PyExc_TypeError, + "type '%.100s' is not dynamically allocated but " + "its base type '%.100s' is dynamically allocated", + type->tp_name, ((PyTypeObject *)b)->tp_name); + goto error; + } + } + /* Sanity check for tp_free. */ if (PyType_IS_GC(type) && (type->tp_flags & Py_TPFLAGS_BASETYPE) && (type->tp_free == NULL || type->tp_free == PyObject_Del)) { |