Skip to content

bpo-38070: Enhance _PyObject_Dump() #16243

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Sep 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Objects/object.c
Original file line number Diff line number Diff line change
Expand Up @@ -464,15 +464,15 @@ void
_PyObject_Dump(PyObject* op)
{
if (op == NULL) {
fprintf(stderr, "<NULL object>\n");
fprintf(stderr, "<object at NULL>\n");
fflush(stderr);
return;
}

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;
}

Expand Down Expand Up @@ -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.
Expand Down