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().
This commit is contained in:
Victor Stinner 2022-01-21 13:05:26 +01:00 committed by GitHub
parent 54610bb448
commit ea38e436fe
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 6 deletions

View File

@ -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.

View File

@ -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.
@ -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