summaryrefslogtreecommitdiffstats
path: root/Objects
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2015-01-28 09:06:04 (GMT)
committerSerhiy Storchaka <storchaka@gmail.com>2015-01-28 09:06:04 (GMT)
commit66acbb28ee6b653b32c361591e7e009ddaf3543c (patch)
treea0464de49b77cdf9ba1b42c35b1189015645ac82 /Objects
parent85ad88dbc6e57d1b66869ebbb5caaa2d1119be4b (diff)
parente09bcc874a21ce351a7fe73b9a137e236550d03c (diff)
downloadcpython-66acbb28ee6b653b32c361591e7e009ddaf3543c.zip
cpython-66acbb28ee6b653b32c361591e7e009ddaf3543c.tar.gz
cpython-66acbb28ee6b653b32c361591e7e009ddaf3543c.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.c14
1 files changed, 14 insertions, 0 deletions
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
index a1b2cb7..4177129 100644
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4683,6 +4683,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)) {