forked from VimPlug/jedi
memoize problems with defaults in combination with raised exceptions
This commit is contained in:
@@ -4,6 +4,8 @@
|
||||
- ``CachedMetaClass`` uses ``memoize_default`` to do the same with classes.
|
||||
"""
|
||||
|
||||
NO_DEFAULT = object()
|
||||
|
||||
|
||||
def memoize_default(default=None, evaluator_is_first_arg=False, second_arg_is_evaluator=False):
|
||||
""" This is a typical memoization decorator, BUT there is one difference:
|
||||
@@ -32,7 +34,8 @@ def memoize_default(default=None, evaluator_is_first_arg=False, second_arg_is_ev
|
||||
if key in memo:
|
||||
return memo[key]
|
||||
else:
|
||||
memo[key] = default
|
||||
if default is not NO_DEFAULT:
|
||||
memo[key] = default
|
||||
rv = function(obj, *args, **kwargs)
|
||||
memo[key] = rv
|
||||
return rv
|
||||
|
||||
Reference in New Issue
Block a user