Fix to inlinefuncs stack cache to make it properly use the cached value.

This commit is contained in:
Griatch 2017-01-29 16:52:06 +01:00
parent 203d0a09a0
commit dcde526f6d

View file

@ -266,14 +266,14 @@ def parse_inlinefunc(string, strip=False, **kwargs):
if string in _PARSING_CACHE:
# stack is already cached
stack = _PARSING_CACHE[string]
else:
# not a cached string.
if not _RE_STARTTOKEN.search(string):
elif not _RE_STARTTOKEN.search(string):
# if there are no unescaped start tokens at all, return immediately.
return string
# build a new cache entry
else:
# no cached stack; build a new stack and continue
stack = ParseStack()
# process string on stack
ncallable = 0
for match in _RE_TOKEN.finditer(string):
gdict = match.groupdict()
@ -329,7 +329,7 @@ def parse_inlinefunc(string, strip=False, **kwargs):
# if stack is larger than limit, throw away parsing
return string + gdict["stackfull"](*args, **kwargs)
else:
# cache the result
# cache the stack
_PARSING_CACHE[string] = stack
# run the stack recursively
@ -356,6 +356,7 @@ def parse_inlinefunc(string, strip=False, **kwargs):
# execute the stack from the cache
return "".join(_run_stack(item) for item in _PARSING_CACHE[string])
#
# Nick templating
#