summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBarry Warsaw <barry@python.org>2001-02-22 22:39:18 (GMT)
committerBarry Warsaw <barry@python.org>2001-02-22 22:39:18 (GMT)
commiteefb107a48fd7afea4ea53cf45ea69ae2b227aa0 (patch)
tree0ffbd024bfb42520c1f0700fe32d76fe6f58317c
parent2da0ea82ba0c817013fca1442d14ee3596f03bcb (diff)
downloadcpython-eefb107a48fd7afea4ea53cf45ea69ae2b227aa0.zip
cpython-eefb107a48fd7afea4ea53cf45ea69ae2b227aa0.tar.gz
cpython-eefb107a48fd7afea4ea53cf45ea69ae2b227aa0.tar.bz2
_PyObject_Dump(): If argument is NULL, print "NULL" instead of
crashing.
-rw-r--r--Objects/object.c10
1 files changed, 7 insertions, 3 deletions
diff --git a/Objects/object.c b/Objects/object.c
index eff6d7a..8a898f8 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -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