From: Victor Stinner Date: Tue, 17 Sep 2019 21:36:28 +0000 (+0200) Subject: bpo-38070: Enhance _PyObject_Dump() (GH-16243) X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=b39afb78768418d9405c4b528c80fa968ccc974d;p=python bpo-38070: Enhance _PyObject_Dump() (GH-16243) _PyObject_Dump() now dumps the object address for freed objects and objects with ob_type=NULL. --- diff --git a/Objects/object.c b/Objects/object.c index 7f2c23a9ff..43ed4c59a7 100644 --- a/Objects/object.c +++ b/Objects/object.c @@ -464,7 +464,7 @@ void _PyObject_Dump(PyObject* op) { if (op == NULL) { - fprintf(stderr, "\n"); + fprintf(stderr, "\n"); fflush(stderr); return; } @@ -472,7 +472,7 @@ _PyObject_Dump(PyObject* op) if (_PyObject_IsFreed(op)) { /* It seems like the object memory has been freed: don't access it to prevent a segmentation fault. */ - fprintf(stderr, "\n"); + fprintf(stderr, "\n", op); return; } @@ -2160,18 +2160,19 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg, fflush(stderr); if (obj == NULL) { - fprintf(stderr, "\n"); + fprintf(stderr, "\n"); } else if (_PyObject_IsFreed(obj)) { /* It seems like the object memory has been freed: don't access it to prevent a segmentation fault. */ - fprintf(stderr, "\n"); + fprintf(stderr, "\n", obj); } else if (Py_TYPE(obj) == NULL) { - fprintf(stderr, "\n"); + fprintf(stderr, "\n", obj); } else if (_PyObject_IsFreed((PyObject *)Py_TYPE(obj))) { - fprintf(stderr, "\n", (void *)Py_TYPE(obj)); + fprintf(stderr, "\n", + obj, (void *)Py_TYPE(obj)); } else { /* Display the traceback where the object has been allocated.