]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-151728: Partially revert "Clear the typing caches at interpreter shutdown (GH...
authorPetr Viktorin <encukou@gmail.com>
Fri, 31 Jul 2026 14:00:12 +0000 (16:00 +0200)
committerGitHub <noreply@github.com>
Fri, 31 Jul 2026 14:00:12 +0000 (16:00 +0200)
Unfortunately, this change causes reference leak tests to fail.

This only reverts the `atexit` registration: it leaves the `_clear_caches` function, to simplify the regrtest utils code a bit.

Lib/typing.py
Misc/NEWS.d/next/Library/2026-07-29-11-05-00.gh-issue-151728.Kq3vTn.rst [deleted file]

index 809c0ff88607a59067cd0061222063eb072bbad0..a05d73c29cf95e58e822334bb7a08e7ae55f177e 100644 (file)
@@ -19,7 +19,6 @@ that may be changed without notice. Use at your own risk!
 """
 
 from abc import abstractmethod, ABCMeta
-import atexit
 import collections
 from collections import defaultdict
 import collections.abc
@@ -398,11 +397,6 @@ def _clear_caches():
         cleanup()
 
 
-# Release the LRU caches at shutdown, they otherwise redistribute reference
-# leaks of one extension to types of unrelated ones. See GH-151728.
-atexit.register(_clear_caches)
-
-
 def _tp_cache(func=None, /, *, typed=False):
     """Internal wrapper caching __getitem__ of generic types.
 
diff --git a/Misc/NEWS.d/next/Library/2026-07-29-11-05-00.gh-issue-151728.Kq3vTn.rst b/Misc/NEWS.d/next/Library/2026-07-29-11-05-00.gh-issue-151728.Kq3vTn.rst
deleted file mode 100644 (file)
index 39c63a1..0000000
+++ /dev/null
@@ -1,4 +0,0 @@
-Clear the internal :mod:`typing` caches from an exit handler. Previously, an
-extension module that leaked a reference to :mod:`typing` would also keep every
-subscripted type alive past interpreter shutdown, including types owned by
-unrelated extension modules.