mirror of
https://github.com/python/cpython.git
synced 2025-09-26 18:29:57 +00:00
bpo-38070: Enhance _PyObject_Dump() (GH-16243)
_PyObject_Dump() now dumps the object address for freed objects and objects with ob_type=NULL.
This commit is contained in:
parent
8fa3e1740b
commit
b39afb7876
1 changed files with 7 additions and 6 deletions
|
@ -464,7 +464,7 @@ void
|
||||||
_PyObject_Dump(PyObject* op)
|
_PyObject_Dump(PyObject* op)
|
||||||
{
|
{
|
||||||
if (op == NULL) {
|
if (op == NULL) {
|
||||||
fprintf(stderr, "<NULL object>\n");
|
fprintf(stderr, "<object at NULL>\n");
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -472,7 +472,7 @@ _PyObject_Dump(PyObject* op)
|
||||||
if (_PyObject_IsFreed(op)) {
|
if (_PyObject_IsFreed(op)) {
|
||||||
/* It seems like the object memory has been freed:
|
/* It seems like the object memory has been freed:
|
||||||
don't access it to prevent a segmentation fault. */
|
don't access it to prevent a segmentation fault. */
|
||||||
fprintf(stderr, "<Freed object>\n");
|
fprintf(stderr, "<object at %p is freed>\n", op);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2160,18 +2160,19 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
|
||||||
fflush(stderr);
|
fflush(stderr);
|
||||||
|
|
||||||
if (obj == NULL) {
|
if (obj == NULL) {
|
||||||
fprintf(stderr, "<NULL object>\n");
|
fprintf(stderr, "<object at NULL>\n");
|
||||||
}
|
}
|
||||||
else if (_PyObject_IsFreed(obj)) {
|
else if (_PyObject_IsFreed(obj)) {
|
||||||
/* It seems like the object memory has been freed:
|
/* It seems like the object memory has been freed:
|
||||||
don't access it to prevent a segmentation fault. */
|
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) {
|
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))) {
|
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 {
|
else {
|
||||||
/* Display the traceback where the object has been allocated.
|
/* Display the traceback where the object has been allocated.
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue