Commit ce16424b authored by Serhiy Storchaka's avatar Serhiy Storchaka

Issue #22079: Py3k warning now is issued in PyType_Ready() instead of

raising TypeError when statically allocated type subclasses dynamically
allocated type
parent 9f696c98
...@@ -4074,16 +4074,19 @@ PyType_Ready(PyTypeObject *type) ...@@ -4074,16 +4074,19 @@ PyType_Ready(PyTypeObject *type)
} }
/* All bases of statically allocated type should be statically allocated */ /* All bases of statically allocated type should be statically allocated */
if (!(type->tp_flags & Py_TPFLAGS_HEAPTYPE)) if (Py_Py3kWarningFlag && !(type->tp_flags & Py_TPFLAGS_HEAPTYPE))
for (i = 0; i < n; i++) { for (i = 0; i < n; i++) {
PyObject *b = PyTuple_GET_ITEM(bases, i); PyObject *b = PyTuple_GET_ITEM(bases, i);
if (PyType_Check(b) && if (PyType_Check(b) &&
(((PyTypeObject *)b)->tp_flags & Py_TPFLAGS_HEAPTYPE)) { (((PyTypeObject *)b)->tp_flags & Py_TPFLAGS_HEAPTYPE)) {
PyErr_Format(PyExc_TypeError, char buf[300];
"type '%.100s' is not dynamically allocated but " PyOS_snprintf(buf, sizeof(buf),
"its base type '%.100s' is dynamically allocated", "type '%.100s' is not dynamically allocated but "
type->tp_name, ((PyTypeObject *)b)->tp_name); "its base type '%.100s' is dynamically allocated",
goto error; type->tp_name, ((PyTypeObject *)b)->tp_name);
if (PyErr_WarnPy3k(buf, 1) < 0)
goto error;
break;
} }
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment