Commit 9c6e70e0 authored by Barry Warsaw's avatar Barry Warsaw

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

crashing.
parent 60bc84a9
...@@ -231,9 +231,13 @@ PyObject_Print(PyObject *op, FILE *fp, int flags) ...@@ -231,9 +231,13 @@ PyObject_Print(PyObject *op, FILE *fp, int flags)
/* For debugging convenience. See Misc/gdbinit for some useful gdb hooks */ /* For debugging convenience. See Misc/gdbinit for some useful gdb hooks */
void _PyObject_Dump(PyObject* op) void _PyObject_Dump(PyObject* op)
{ {
if (op == NULL)
fprintf(stderr, "NULL\n");
else {
(void)PyObject_Print(op, stderr, 0); (void)PyObject_Print(op, stderr, 0);
fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt); fprintf(stderr, "\nrefcounts: %d\n", op->ob_refcnt);
fprintf(stderr, "address : %p\n", op); fprintf(stderr, "address : %p\n", op);
}
} }
#ifdef WITH_CYCLE_GC #ifdef WITH_CYCLE_GC
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment