Mercurial > cpython-lru_cache-weakref
diff Objects/typeobject.c @ 40067:eda931f398c0 2.4
[Backport r42951 | guido.van.rossum]
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]
| author | Andrew M. Kuchling <amk@amk.ca> |
|---|---|
| date | Mon, 09 Oct 2006 18:19:01 +0000 |
| parents | ab13576374b1 |
| children | fc46abf170fd |
line wrap: on
line diff
--- a/Objects/typeobject.c Mon Oct 09 17:15:39 2006 +0000 +++ b/Objects/typeobject.c Mon Oct 09 18:19:01 2006 +0000 @@ -3712,7 +3712,9 @@ 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 @@ 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,
