1
0
mirror of https://github.com/nvbn/thefuck.git synced 2025-01-19 12:24:29 +00:00

Merge pull request #400 from alessio/fix-memoize

Fix misinterpretation of the disabled flag
This commit is contained in:
Vladimir Iakovlev 2015-11-06 02:19:07 +08:00
commit fe91008a9c

View File

@ -23,11 +23,16 @@ def memoize(fn):
@wraps(fn) @wraps(fn)
def wrapper(*args, **kwargs): def wrapper(*args, **kwargs):
if not memoize.disabled:
key = pickle.dumps((args, kwargs)) key = pickle.dumps((args, kwargs))
if key not in memo or memoize.disabled: if key not in memo:
memo[key] = fn(*args, **kwargs) memo[key] = fn(*args, **kwargs)
value = memo[key]
else:
# Memoize is disabled, call the function
value = fn(*args, **kwargs)
return memo[key] return value
return wrapper return wrapper
memoize.disabled = False memoize.disabled = False