Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 411fd55

Browse files
committed
added a comment clarifying the indirection
1 parent 2fed985 commit 411fd55

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

Lib/typing.py

+5
Original file line numberDiff line numberDiff line change
@@ -352,6 +352,11 @@ def _tp_cache(func=None, /, *, typed=False):
352352
original function for non-hashable arguments.
353353
"""
354354
def decorator(func):
355+
# The callback 'inner' references the newly created lru_cache
356+
# indirectly by performing a lookup in the global '_caches' dictionary.
357+
# This breaks a reference that can be problematic when combined with
358+
# C API extensions that leak references to types. See GH-98253.
359+
355360
cache = functools.lru_cache(typed=typed)(func)
356361
_caches[func] = cache
357362
_cleanups.append(cache.cache_clear)

0 commit comments

Comments
 (0)