diff options
author | Eric Snow <ericsnowcurrently@gmail.com> | 2024-06-14 15:29:09 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2024-06-14 13:29:09 -0600 |
commit | b2e71ff4f8fa5b7d8117dd8125137aee3d01f015 (patch) | |
tree | 76ffcadb4db306b4776329e3cf197fe0cd7894bc /Python/pylifecycle.c | |
parent | 05df063ad80becc1ba6bd07d67b55b5965f32375 (diff) | |
download | cpython-b2e71ff4f8fa5b7d8117dd8125137aee3d01f015.tar.gz cpython-b2e71ff4f8fa5b7d8117dd8125137aee3d01f015.zip |
gh-120161: Fix a Crash in the _datetime Module (gh-120182)
In gh-120009 I used an atexit hook to finalize the _datetime module's static types at interpreter shutdown. However, atexit hooks are executed very early in finalization, which is a problem in the few cases where a subclass of one of those static types is still alive until the final GC collection. The static builtin types don't have this probably because they are finalized toward the end, after the final GC collection. To avoid the problem for _datetime, I have applied a similar approach here.
Also, credit goes to @mgorny and @neonene for the new tests.
FYI, I would have liked to take a slightly cleaner approach with managed static types, but wanted to get a smaller fix in first for the sake of backporting. I'll circle back to the cleaner approach with a future change on the main branch.
Diffstat (limited to 'Python/pylifecycle.c')
-rw-r--r-- | Python/pylifecycle.c | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/Python/pylifecycle.c b/Python/pylifecycle.c index cbdf5c1b771..3639cf67120 100644 --- a/Python/pylifecycle.c +++ b/Python/pylifecycle.c @@ -1818,6 +1818,7 @@ flush_std_files(void) static void finalize_interp_types(PyInterpreterState *interp) { + _PyTypes_FiniExtTypes(interp); _PyUnicode_FiniTypes(interp); _PySys_FiniTypes(interp); _PyXI_FiniTypes(interp); |