]> granicus.if.org Git - python/commitdiff
_PyObject_Dump(): If argument is NULL, print "NULL" instead of
authorBarry Warsaw <barry@python.org>
Thu, 22 Feb 2001 22:39:18 +0000 (22:39 +0000)
committerBarry Warsaw <barry@python.org>
Thu, 22 Feb 2001 22:39:18 +0000 (22:39 +0000)
crashing.

Objects/object.c

index eff6d7ad072ac37a642076fd5e1e0fd4fda803b7..8a898f8bbf6b978f456eb33b81c720fbf83c7beb 100644 (file)
@@ -231,9 +231,13 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
 /* For debugging convenience.  See Misc/gdbinit for some useful gdb hooks */
 void _PyObject_Dump(PyObject* op) 
 {
-       (void)PyObject_Print(op, stderr, 0);
-       fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt);
-       fprintf(stderr, "address    : %p\n", op);
+       if (op == NULL)
+               fprintf(stderr, "NULL\n");
+       else {
+               (void)PyObject_Print(op, stderr, 0);
+               fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt);
+               fprintf(stderr, "address    : %p\n", op);
+       }
 }
 
 #ifdef WITH_CYCLE_GC