From b39afb78768418d9405c4b528c80fa968ccc974d Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Tue, 17 Sep 2019 23:36:28 +0200 Subject: [PATCH] bpo-38070: Enhance _PyObject_Dump() (GH-16243) _PyObject_Dump() now dumps the object address for freed objects and objects with ob_type=NULL. --- Objects/object.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/Objects/object.c b/Objects/object.c index 7f2c23a9ff8..43ed4c59a71 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.