aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/Python/sysmodule.c
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2022-01-21 01:42:25 +0100
committerGitHub <noreply@github.com>2022-01-21 01:42:25 +0100
commite9e3eab0b868c7d0b48e472705024240d5c39d5c (patch)
tree65c254d948a37dd822085887ebb84f390ad48d94 /Python/sysmodule.c
parent27df7566bc19699b967e0e30d7808637b90141f6 (diff)
downloadcpython-e9e3eab0b868c7d0b48e472705024240d5c39d5c.tar.gz
cpython-e9e3eab0b868c7d0b48e472705024240d5c39d5c.zip
bpo-46417: Finalize structseq types at exit (GH-30645)
Add _PyStructSequence_FiniType() and _PyStaticType_Dealloc() functions to finalize a structseq static type in Py_Finalize(). Currrently, these functions do nothing if Python is built in release mode. Clear static types: * AsyncGenHooksType: sys.set_asyncgen_hooks() * FlagsType: sys.flags * FloatInfoType: sys.float_info * Hash_InfoType: sys.hash_info * Int_InfoType: sys.int_info * ThreadInfoType: sys.thread_info * UnraisableHookArgsType: sys.unraisablehook * VersionInfoType: sys.version * WindowsVersionType: sys.getwindowsversion()
Diffstat (limited to 'Python/sysmodule.c')
-rw-r--r--Python/sysmodule.c15
1 files changed, 15 insertions, 0 deletions
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 0b7b61d8b1e..515994f0490 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -3102,6 +3102,21 @@ error:
}
+void
+_PySys_Fini(PyInterpreterState *interp)
+{
+ if (_Py_IsMainInterpreter(interp)) {
+ _PyStructSequence_FiniType(&VersionInfoType);
+ _PyStructSequence_FiniType(&FlagsType);
+#if defined(MS_WINDOWS)
+ _PyStructSequence_FiniType(&WindowsVersionType);
+#endif
+ _PyStructSequence_FiniType(&Hash_InfoType);
+ _PyStructSequence_FiniType(&AsyncGenHooksType);
+ }
+}
+
+
static PyObject *
makepathobject(const wchar_t *path, wchar_t delim)
{