diff options
Diffstat (limited to 'lib/spack/external/jinja2/asyncsupport.py')
-rw-r--r-- | lib/spack/external/jinja2/asyncsupport.py | 14 |
1 files changed, 8 insertions, 6 deletions
diff --git a/lib/spack/external/jinja2/asyncsupport.py b/lib/spack/external/jinja2/asyncsupport.py index f4f264ad8c..b1e7b5ce9a 100644 --- a/lib/spack/external/jinja2/asyncsupport.py +++ b/lib/spack/external/jinja2/asyncsupport.py @@ -189,9 +189,9 @@ async def auto_aiter(iterable): class AsyncLoopContext(LoopContextBase): - def __init__(self, async_iterator, after, length, recurse=None, + def __init__(self, async_iterator, undefined, after, length, recurse=None, depth0=0): - LoopContextBase.__init__(self, recurse, depth0) + LoopContextBase.__init__(self, undefined, recurse, depth0) self._async_iterator = async_iterator self._after = after self._length = length @@ -221,15 +221,16 @@ class AsyncLoopContextIterator(object): ctx.index0 += 1 if ctx._after is _last_iteration: raise StopAsyncIteration() - next_elem = ctx._after + ctx._before = ctx._current + ctx._current = ctx._after try: ctx._after = await ctx._async_iterator.__anext__() except StopAsyncIteration: ctx._after = _last_iteration - return next_elem, ctx + return ctx._current, ctx -async def make_async_loop_context(iterable, recurse=None, depth0=0): +async def make_async_loop_context(iterable, undefined, recurse=None, depth0=0): # Length is more complicated and less efficient in async mode. The # reason for this is that we cannot know if length will be used # upfront but because length is a property we cannot lazily execute it @@ -251,4 +252,5 @@ async def make_async_loop_context(iterable, recurse=None, depth0=0): after = await async_iterator.__anext__() except StopAsyncIteration: after = _last_iteration - return AsyncLoopContext(async_iterator, after, length, recurse, depth0) + return AsyncLoopContext(async_iterator, undefined, after, length, recurse, + depth0) |