cpython: c087ac6fc171 (original) (raw)
Mercurial > cpython
changeset 94348:c087ac6fc171 2.7
Issue #22079: PyType_Ready() now checks that statically allocated type has no dynamically allocated bases. [#22079]
Serhiy Storchaka storchaka@gmail.com | |
---|---|
date | Wed, 28 Jan 2015 10:52:49 +0200 |
parents | 1f07af946fe8 |
children | 1addc4f0f10c |
files | Misc/NEWS Objects/typeobject.c |
diffstat | 2 files changed, 20 insertions(+), 0 deletions(-)[+] [-] Misc/NEWS 6 Objects/typeobject.c 14 |
line wrap: on
line diff
--- a/Misc/NEWS +++ b/Misc/NEWS @@ -117,6 +117,12 @@ Build
- Issue #23212: Update 10.5 OS X installer build to use OpenSSL 1.0.1k. +C API +----- + +- Issue #22079: PyType_Ready() now checks that statically allocated type has
--- 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++) {[](#l2.9)
PyObject *b = PyTuple_GET_ITEM(bases, i);[](#l2.10)
if (PyType_Check(b) &&[](#l2.11)
(((PyTypeObject *)b)->tp_flags & Py_TPFLAGS_HEAPTYPE)) {[](#l2.12)
PyErr_Format(PyExc_TypeError,[](#l2.13)
"type '%.100s' is not dynamically allocated but "[](#l2.14)
"its base type '%.100s' is dynamically allocated",[](#l2.15)
type->tp_name, ((PyTypeObject *)b)->tp_name);[](#l2.16)
goto error;[](#l2.17)
}[](#l2.18)
}[](#l2.19)
+ /* 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)) {