]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[Backport r42951 | guido.van.rossum]
authorAndrew M. Kuchling <amk@amk.ca>
Mon, 9 Oct 2006 18:19:01 +0000 (18:19 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Mon, 9 Oct 2006 18:19:01 +0000 (18:19 +0000)
Fix three nits found by Coverity, adding null checks and comments.

[This commit only makes two changes.  One change in the original patch
 is just adding a comment, and another adds a 'base != NULL' check to
 silence Coverity, but a comment adds that that base is never going to
 be NULL.  I didn't backport that change. --amk]

Objects/typeobject.c

index 0bed8cc692adb273864cdf693252e78a82478011..295634c0a831d610e3a66b9502865437c0da4c60 100644 (file)
@@ -3712,7 +3712,9 @@ hackcheck(PyObject *self, setattrofunc func, char *what)
        PyTypeObject *type = self->ob_type;
        while (type && type->tp_flags & Py_TPFLAGS_HEAPTYPE)
                type = type->tp_base;
-       if (type->tp_setattro != func) {
+       /* If type is NULL now, this is a really weird type.
+          In the spirit of backwards compatibility (?), just shut up. */
+       if (type && type->tp_setattro != func) {
                PyErr_Format(PyExc_TypeError,
                             "can't apply this %s to %s object",
                             what,
@@ -3927,7 +3929,9 @@ tp_new_wrapper(PyObject *self, PyObject *args, PyObject *kwds)
        staticbase = subtype;
        while (staticbase && (staticbase->tp_flags & Py_TPFLAGS_HEAPTYPE))
                staticbase = staticbase->tp_base;
-       if (staticbase->tp_new != type->tp_new) {
+       /* If staticbase is NULL now, this is a really weird type.
+          In the spirit of backwards compatibility (?), just shut up. */
+       if (staticbase && staticbase->tp_new != type->tp_new) {
                PyErr_Format(PyExc_TypeError,
                             "%s.__new__(%s) is not safe, use %s.__new__()",
                             type->tp_name,