From 22e6cb8ec2dd41b38503083612ff1c3fba2a1d99 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Fri, 21 Jan 2022 12:21:30 +0100 Subject: [PATCH] bpo-46417: Call _PyDebug_PrintTotalRefs() later "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(). --- .../2022-01-21-12-24-14.bpo-46417.i3IqMf.rst | 3 +++ Python/pylifecycle.c | 12 ++++++------ 2 files changed, 9 insertions(+), 6 deletions(-) create mode 100644 Misc/NEWS.d/next/Core and Builtins/2022-01-21-12-24-14.bpo-46417.i3IqMf.rst diff --git a/Misc/NEWS.d/next/Core and Builtins/2022-01-21-12-24-14.bpo-46417.i3IqMf.rst b/Misc/NEWS.d/next/Core and Builtins/2022-01-21-12-24-14.bpo-46417.i3IqMf.rst new file mode 100644 index 00000000000000..c7e2ee33500d95 --- /dev/null +++ b/Misc/NEWS.d/next/Core and Builtins/2022-01-21-12-24-14.bpo-46417.i3IqMf.rst @@ -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. diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index 0b1f47147696d6..5572f61c7288a2 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -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 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