summaryrefslogtreecommitdiffstats
path: root/Objects/object.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@redhat.com>2019-09-17 21:36:28 (GMT)
committerGitHub <noreply@github.com>2019-09-17 21:36:28 (GMT)
commitb39afb78768418d9405c4b528c80fa968ccc974d (patch)
tree2a414c8d55c5a56ee7785842f748c03bd0c60ddc /Objects/object.c
parent8fa3e1740b3f03ea65ddb68411c2238c5f98eec2 (diff)
downloadcpython-b39afb78768418d9405c4b528c80fa968ccc974d.zip
cpython-b39afb78768418d9405c4b528c80fa968ccc974d.tar.gz
cpython-b39afb78768418d9405c4b528c80fa968ccc974d.tar.bz2
bpo-38070: Enhance _PyObject_Dump() (GH-16243)
_PyObject_Dump() now dumps the object address for freed objects and objects with ob_type=NULL.
Diffstat (limited to 'Objects/object.c')
-rw-r--r--Objects/object.c13
1 files changed, 7 insertions, 6 deletions
diff --git a/Objects/object.c b/Objects/object.c
index 7f2c23a..43ed4c5 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -464,7 +464,7 @@ void
_PyObject_Dump(PyObject* op)
{
if (op == NULL) {
- fprintf(stderr, "<NULL object>\n");
+ fprintf(stderr, "<object at NULL>\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, "<Freed object>\n");
+ fprintf(stderr, "<object at %p is freed>\n", op);
return;
}
@@ -2160,18 +2160,19 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
fflush(stderr);
if (obj == NULL) {
- fprintf(stderr, "<NULL object>\n");
+ fprintf(stderr, "<object at NULL>\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, "<object: freed>\n");
+ fprintf(stderr, "<object at %p is freed>\n", obj);
}
else if (Py_TYPE(obj) == NULL) {
- fprintf(stderr, "<object: ob_type=NULL>\n");
+ fprintf(stderr, "<object at %p: ob_type=NULL>\n", obj);
}
else if (_PyObject_IsFreed((PyObject *)Py_TYPE(obj))) {
- fprintf(stderr, "<object: freed type %p>\n", (void *)Py_TYPE(obj));
+ fprintf(stderr, "<object at %p: type at %p is freed>\n",
+ obj, (void *)Py_TYPE(obj));
}
else {
/* Display the traceback where the object has been allocated.