changeset: 94349:747855f29b9d branch: 3.4 parent: 94346:eecaa42e0c06 user: Serhiy Storchaka date: Wed Jan 28 11:03:33 2015 +0200 files: Misc/NEWS Objects/typeobject.c description: Issue #22079: PyType_Ready() now checks that statically allocated type has no dynamically allocated bases. diff -r eecaa42e0c06 -r 747855f29b9d Misc/NEWS --- a/Misc/NEWS Wed Jan 28 07:32:38 2015 +0000 +++ b/Misc/NEWS Wed Jan 28 11:03:33 2015 +0200 @@ -332,6 +332,12 @@ - Issue #17128: Use private version of OpenSSL for 2.7.9 OS X 10.5+ installer. +C API +----- + +- Issue #22079: PyType_Ready() now checks that statically allocated type has + no dynamically allocated bases. + Documentation ------------- @@ -1136,6 +1142,7 @@ C API ----- + - Issue #20942: PyImport_ImportFrozenModuleObject() no longer sets __file__ to match what importlib does; this affects _frozen_importlib as well as any module loaded using imp.init_frozen(). diff -r eecaa42e0c06 -r 747855f29b9d Objects/typeobject.c --- a/Objects/typeobject.c Wed Jan 28 07:32:38 2015 +0000 +++ b/Objects/typeobject.c Wed Jan 28 11:03:33 2015 +0200 @@ -4680,6 +4680,20 @@ 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)) {