From: Petr Viktorin Date: Fri, 31 Jul 2026 14:00:12 +0000 (+0200) Subject: gh-151728: Partially revert "Clear the typing caches at interpreter shutdown (GH... X-Git-Url: http://git.ipfire.org/gitweb/?a=commitdiff_plain;h=6a139d6e5481d2b5124b84cef9885674256c9d54;p=thirdparty%2FPython%2Fcpython.git gh-151728: Partially revert "Clear the typing caches at interpreter shutdown (GH-154858)" (GH-154992) 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. --- diff --git a/Lib/typing.py b/Lib/typing.py index 809c0ff88607..a05d73c29cf9 100644 --- a/Lib/typing.py +++ b/Lib/typing.py @@ -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 index 39c63a1aea31..000000000000 --- a/Misc/NEWS.d/next/Library/2026-07-29-11-05-00.gh-issue-151728.Kq3vTn.rst +++ /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.