Fixes CI/CD errors
Some checks failed
/ build (macos-latest, 3.8) (push) Has been cancelled
/ build (ubuntu-latest, pypy-2.7) (push) Has been cancelled
/ build (windows-latest, 3.14) (push) Has been cancelled

This commit is contained in:
Miroslav Štampar 2026-10-27 13:47:04 +01:00
parent 81d17b1ad2
commit f8a42cf016
2 changed files with 11 additions and 9 deletions

View file

@ -61,10 +61,11 @@ def cachedmethod(f):
key = args
with lock:
try:
return cache[key]
except KeyError: # Note: single lookup, as an entry can get evicted in between (unlocked on Python 3)
pass
if key in cache:
try:
return cache[key]
except KeyError: # Note: evicted in between (unlocked on Python 3)
pass
except TypeError:
# Note: fallback (slow-path) for unhashable arguments
@ -75,10 +76,11 @@ def cachedmethod(f):
key = (_FROZEN_KEY_MARKER, _freeze(args))
with lock:
try:
return cache[key]
except KeyError:
pass
if key in cache:
try:
return cache[key]
except KeyError:
pass
except TypeError:
# Note: genuinely uncacheable arguments; skip caching altogether
return f(*args, **kwargs)