_PyObject_Dump(): If argument is NULL, print "NULL" instead of

crashing.
This commit is contained in:
Barry Warsaw 2001-02-22 22:39:18 +00:00
parent 2da0ea82ba
commit eefb107a48
1 changed files with 7 additions and 3 deletions

View 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