]> granicus.if.org Git - python/commitdiff
Issue #22079: Deprecation warning now is issued in PyType_Ready() instead of
authorSerhiy Storchaka <storchaka@gmail.com>
Sun, 22 Mar 2015 07:46:36 +0000 (09:46 +0200)
committerSerhiy Storchaka <storchaka@gmail.com>
Sun, 22 Mar 2015 07:46:36 +0000 (09:46 +0200)
raising TypeError when statically allocated type subclasses dynamically
allocated type

Objects/typeobject.c

index cf5891120902dbd598c94d88d838483c08ef95a6..0fccecdc361409e977619709c6e5bb05e78d42ef 100644 (file)
@@ -4803,11 +4803,14 @@ PyType_Ready(PyTypeObject *type)
             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_Warn(PyExc_DeprecationWarning, buf) < 0)
+                    goto error;
+                break;
             }
         }