bpo-38070: Enhance _PyObject_Dump() (GH-16243) · python/cpython@b39afb7 (original) (raw)
`@@ -464,15 +464,15 @@ void
`
464
464
`_PyObject_Dump(PyObject* op)
`
465
465
`{
`
466
466
`if (op == NULL) {
`
467
``
`-
fprintf(stderr, "\n");
`
``
467
`+
fprintf(stderr, "\n");
`
468
468
`fflush(stderr);
`
469
469
`return;
`
470
470
` }
`
471
471
``
472
472
`if (_PyObject_IsFreed(op)) {
`
473
473
`/* It seems like the object memory has been freed:
`
474
474
` don't access it to prevent a segmentation fault. */
`
475
``
`-
fprintf(stderr, "\n");
`
``
475
`+
fprintf(stderr, "<object at %p is freed>\n", op);
`
476
476
`return;
`
477
477
` }
`
478
478
``
`@@ -2160,18 +2160,19 @@ _PyObject_AssertFailed(PyObject *obj, const char *expr, const char *msg,
`
2160
2160
`fflush(stderr);
`
2161
2161
``
2162
2162
`if (obj == NULL) {
`
2163
``
`-
fprintf(stderr, "\n");
`
``
2163
`+
fprintf(stderr, "\n");
`
2164
2164
` }
`
2165
2165
`else if (_PyObject_IsFreed(obj)) {
`
2166
2166
`/* It seems like the object memory has been freed:
`
2167
2167
` don't access it to prevent a segmentation fault. */
`
2168
``
`-
fprintf(stderr, "<object: freed>\n");
`
``
2168
`+
fprintf(stderr, "<object at %p is freed>\n", obj);
`
2169
2169
` }
`
2170
2170
`else if (Py_TYPE(obj) == NULL) {
`
2171
``
`-
fprintf(stderr, "<object: ob_type=NULL>\n");
`
``
2171
`+
fprintf(stderr, "<object at %p: ob_type=NULL>\n", obj);
`
2172
2172
` }
`
2173
2173
`else if (_PyObject_IsFreed((PyObject *)Py_TYPE(obj))) {
`
2174
``
`-
fprintf(stderr, "<object: freed type %p>\n", (void *)Py_TYPE(obj));
`
``
2174
`+
fprintf(stderr, "<object at %p: type at %p is freed>\n",
`
``
2175
`+
obj, (void *)Py_TYPE(obj));
`
2175
2176
` }
`
2176
2177
`else {
`
2177
2178
`/* Display the traceback where the object has been allocated.
`