[Python-checkins] cpython (2.7): Issue #22079: Py3k warning now is issued in PyType_Ready() instead of
serhiy.storchaka
python-checkins at python.org
Sun Mar 22 08:48:13 CET 2015
https://hg.python.org/cpython/rev/aa79a04e9bf5
changeset: 95118:aa79a04e9bf5
branch: 2.7
user: Serhiy Storchaka <storchaka at gmail.com>
date: Sun Mar 22 09:45:35 2015 +0200
summary:
Issue #22079: Py3k warning now is issued in PyType_Ready() instead of
raising TypeError when statically allocated type subclasses dynamically
allocated type
files:
Objects/typeobject.c | 15 +++++++++------
1 files changed, 9 insertions(+), 6 deletions(-)
diff --git a/Objects/typeobject.c b/Objects/typeobject.c
--- a/Objects/typeobject.c
+++ b/Objects/typeobject.c
@@ -4074,16 +4074,19 @@
}
/* 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++) {
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;
+ char buf[300];
+ PyOS_snprintf(buf, sizeof(buf),
+ "type '%.100s' is not dynamically allocated but "
+ "its base type '%.100s' is dynamically allocated",
+ type->tp_name, ((PyTypeObject *)b)->tp_name);
+ if (PyErr_WarnPy3k(buf, 1) < 0)
+ goto error;
+ break;
}
}
--
Repository URL: https://hg.python.org/cpython
More information about the Python-checkins
mailing list