summaryrefslogtreecommitdiff
path: root/Python
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-04-17 19:52:29 +0000
committerTim Peters <tim.peters@gmail.com>2003-04-17 19:52:29 +0000
commit269b2a6797a11958929a5c1102dd1dd67d29e411 (patch)
tree37287664d133867925f963734231c9a08af052f6 /Python
parenta4ea603b055533e71920a088acb1c106e4895dbd (diff)
downloadcpython-git-269b2a6797a11958929a5c1102dd1dd67d29e411.tar.gz
_Py_PrintReferences(): Changed to print object address at start of each
new line. New pvt API function _Py_PrintReferenceAddresses(): Prints only the addresses and refcnts of the live objects. This is always safe to call, because it has no dependence on Python's C API. Py_Finalize(): If envar PYTHONDUMPREFS is set, call (the new) _Py_PrintReferenceAddresses() right before dumping final pymalloc stats. We can't print the reprs of the objects here because too much of the interpreter has been shut down. You need to correlate the addresses displayed here with the object reprs printed by the earlier PYTHONDUMPREFS call to _Py_PrintReferences().
Diffstat (limited to 'Python')
-rw-r--r--Python/pythonrun.c11
1 files changed, 9 insertions, 2 deletions
diff --git a/Python/pythonrun.c b/Python/pythonrun.c
index 4cfb664a27..0a9a63723c 100644
--- a/Python/pythonrun.c
+++ b/Python/pythonrun.c
@@ -284,9 +284,8 @@ Py_Finalize(void)
* Alas, a lot of stuff may still be alive now that will be cleaned
* up later.
*/
- if (Py_GETENV("PYTHONDUMPREFS")) {
+ if (Py_GETENV("PYTHONDUMPREFS"))
_Py_PrintReferences(stderr);
- }
#endif /* Py_TRACE_REFS */
/* Now we decref the exception classes. After this point nothing
@@ -325,6 +324,14 @@ Py_Finalize(void)
PyGrammar_RemoveAccelerators(&_PyParser_Grammar);
+#ifdef Py_TRACE_REFS
+ /* Display addresses (& refcnts) of all objects still alive.
+ * An address can be used to find the repr of the object, printed
+ * above by _Py_PrintReferences.
+ */
+ if (Py_GETENV("PYTHONDUMPREFS"))
+ _Py_PrintReferenceAddresses(stderr);
+#endif /* Py_TRACE_REFS */
#ifdef PYMALLOC_DEBUG
if (Py_GETENV("PYTHONMALLOCSTATS"))
_PyObject_DebugMallocStats();