Skip to content

Commit

Permalink
Merge pull request #400 from alessio/fix-memoize
Browse files Browse the repository at this point in the history
Fix misinterpretation of the disabled flag
  • Loading branch information
nvbn committed Nov 5, 2015
2 parents 89f868c + 7f77721 commit fe91008
Showing 1 changed file with 9 additions and 4 deletions.
13 changes: 9 additions & 4 deletions thefuck/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,11 +23,16 @@ def memoize(fn):

@wraps(fn)
def wrapper(*args, **kwargs):
key = pickle.dumps((args, kwargs))
if key not in memo or memoize.disabled:
memo[key] = fn(*args, **kwargs)
if not memoize.disabled:
key = pickle.dumps((args, kwargs))
if key not in memo:
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
memoize.disabled = False
Expand Down

0 comments on commit fe91008

Please sign in to comment.