Skip to content

bpo-46417: Call _PyDebug_PrintTotalRefs() later #30744

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
Jan 21, 2022
Merged
Show file tree
Hide file tree
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
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
``python -X showrefcount`` now shows the total reference count after clearing
and destroyed the main Python interpreter. Previously, it was shown before.
Patch by Victor Stinner.
12 changes: 6 additions & 6 deletions Python/pylifecycle.c
Original file line number Diff line number Diff line change
Expand Up @@ -1862,12 +1862,6 @@ Py_FinalizeEx(void)
/* dump hash stats */
_PyHash_Fini();

#ifdef Py_REF_DEBUG
if (show_ref_count) {
_PyDebug_PrintTotalRefs();
}
#endif

#ifdef Py_TRACE_REFS
/* Display all objects still alive -- this can invoke arbitrary
* __repr__ overrides, so requires a mostly-intact interpreter.
Expand Down Expand Up @@ -1895,6 +1889,12 @@ Py_FinalizeEx(void)
finalize_interp_clear(tstate);
finalize_interp_delete(tstate->interp);

#ifdef Py_REF_DEBUG
if (show_ref_count) {
_PyDebug_PrintTotalRefs();
}
#endif

#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
Expand Down