[Python-checkins] r52246 - python/branches/release24-maint/Objects/typeobject.c
andrew.kuchling
python-checkins at python.org
Mon Oct 9 20:19:02 CEST 2006
Author: andrew.kuchling
Date: Mon Oct 9 20:19:01 2006
New Revision: 52246
Modified:
python/branches/release24-maint/Objects/typeobject.c
Log:
[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]
Modified: python/branches/release24-maint/Objects/typeobject.c
==============================================================================
--- python/branches/release24-maint/Objects/typeobject.c (original)
+++ python/branches/release24-maint/Objects/typeobject.c Mon Oct 9 20:19:01 2006
@@ -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,
More information about the Python-checkins
mailing list