Merge pull request #41014 from cachedout/issue_40937

Ensure strings in decorator
This commit is contained in:
Mike Place 2017-06-20 15:36:00 -05:00 committed by GitHub
commit eb0e40a867

View File

@ -245,6 +245,14 @@ def memoize(func):
@wraps(func)
def _memoize(*args, **kwargs):
str_args = []
for arg in args:
if not isinstance(arg, six.string_types):
str_args.append(str(arg))
else:
str_args.append(arg)
args = str_args
args_ = ','.join(list(args) + ['{0}={1}'.format(k, kwargs[k]) for k in sorted(kwargs)])
if args_ not in cache:
cache[args_] = func(*args, **kwargs)