mirror of
https://github.com/python/cpython.git
synced 2025-12-04 08:34:25 +00:00
Issue #22079: Deprecation warning now is issued in PyType_Ready() instead of
raising TypeError when statically allocated type subclasses dynamically allocated type
This commit is contained in:
parent
52027c301a
commit
d357b89f0b
1 changed files with 8 additions and 5 deletions
|
|
@ -4803,11 +4803,14 @@ PyType_Ready(PyTypeObject *type)
|
||||||
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];
|
||||||
|
PyOS_snprintf(buf, sizeof(buf),
|
||||||
"type '%.100s' is not dynamically allocated but "
|
"type '%.100s' is not dynamically allocated but "
|
||||||
"its base type '%.100s' is dynamically allocated",
|
"its base type '%.100s' is dynamically allocated",
|
||||||
type->tp_name, ((PyTypeObject *)b)->tp_name);
|
type->tp_name, ((PyTypeObject *)b)->tp_name);
|
||||||
|
if (PyErr_Warn(PyExc_DeprecationWarning, buf) < 0)
|
||||||
goto error;
|
goto error;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue