Skip to content

Commit ea38e43

Browse files
authored
bpo-46417: Call _PyDebug_PrintTotalRefs() later (GH-30744)
"python -X showrefcount" now shows the total reference count after clearing and destroyed the main Python interpreter. Previously, it was shown before. Py_FinalizeEx() now calls _PyDebug_PrintTotalRefs() after finalize_interp_delete().
1 parent 54610bb commit ea38e43

File tree

2 files changed

+9
-6
lines changed

2 files changed

+9
-6
lines changed
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
``python -X showrefcount`` now shows the total reference count after clearing
2+
and destroyed the main Python interpreter. Previously, it was shown before.
3+
Patch by Victor Stinner.

Python/pylifecycle.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1862,12 +1862,6 @@ Py_FinalizeEx(void)
18621862
/* dump hash stats */
18631863
_PyHash_Fini();
18641864

1865-
#ifdef Py_REF_DEBUG
1866-
if (show_ref_count) {
1867-
_PyDebug_PrintTotalRefs();
1868-
}
1869-
#endif
1870-
18711865
#ifdef Py_TRACE_REFS
18721866
/* Display all objects still alive -- this can invoke arbitrary
18731867
* __repr__ overrides, so requires a mostly-intact interpreter.
@@ -1895,6 +1889,12 @@ Py_FinalizeEx(void)
18951889
finalize_interp_clear(tstate);
18961890
finalize_interp_delete(tstate->interp);
18971891

1892+
#ifdef Py_REF_DEBUG
1893+
if (show_ref_count) {
1894+
_PyDebug_PrintTotalRefs();
1895+
}
1896+
#endif
1897+
18981898
#ifdef Py_TRACE_REFS
18991899
/* Display addresses (& refcnts) of all objects still alive.
19001900
* An address can be used to find the repr of the object, printed

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy