]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-151728: Clear the typing caches at interpreter shutdown (GH-154858)
authorWenzel Jakob <wenzel.jakob@epfl.ch>
Thu, 30 Jul 2026 12:00:08 +0000 (14:00 +0200)
committerGitHub <noreply@github.com>
Thu, 30 Jul 2026 12:00:08 +0000 (14:00 +0200)
commit22a6c51c94a4fde986b8964f1d36d5ec3ac20dcc
tree5ddea988388b90396a120d43f8596ecb29665ea3
parentf4b1d3e891d0d2055e53df3ccb84030bcaa148b5
gh-151728: Clear the typing caches at interpreter shutdown (GH-154858)

The typing module caches every subscripted type. When an extension module
leaks a reference to typing, these caches also keep types owned by other
(correct) extension modules alive past interpreter shutdown, where nothing
can free them anymore. The cache_clear callables are already collected in
typing._cleanups, so registering them with atexit is enough to avoid this.
Lib/test/libregrtest/utils.py
Lib/typing.py
Misc/NEWS.d/next/Library/2026-07-29-11-05-00.gh-issue-151728.Kq3vTn.rst [new file with mode: 0644]