From: Armin Ronacher Date: Tue, 24 Jan 2017 19:22:19 +0000 (+0100) Subject: Resolved extends errors in async mode (Fixes #668) X-Git-Tag: 2.9.5~4 X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=8df94bd3447b0432ef41540abe67e5f46920af75;p=thirdparty%2Fjinja.git Resolved extends errors in async mode (Fixes #668) --- diff --git a/CHANGES b/CHANGES index faa319c0..be330892 100644 --- a/CHANGES +++ b/CHANGES @@ -13,6 +13,8 @@ Version 2.9.5 - Correctly use the buffer for the else block of for loops. This caused invalid syntax errors to be caused on 2.x and completely wrong behavior on Python 3 (#669) +- Resolve an issue where the `{% extends %}` tag could not be used with + async environments. (#668) Version 2.9.4 ------------- diff --git a/jinja2/compiler.py b/jinja2/compiler.py index 0765675e..b2ab6fe6 100644 --- a/jinja2/compiler.py +++ b/jinja2/compiler.py @@ -734,12 +734,13 @@ class CodeGenerator(NodeVisitor): self.indent() self.writeline('if parent_template is not None:') self.indent() - if supports_yield_from: + if supports_yield_from and not self.environment.is_async: self.writeline('yield from parent_template.' 'root_render_func(context)') else: - self.writeline('for event in parent_template.' - 'root_render_func(context):') + self.writeline('%sfor event in parent_template.' + 'root_render_func(context):' % + (self.environment.is_async and 'async ' or '')) self.indent() self.writeline('yield event') self.outdent() diff --git a/tests/test_async.py b/tests/test_async.py index bd3ef50a..8618d8d0 100644 --- a/tests/test_async.py +++ b/tests/test_async.py @@ -464,3 +464,7 @@ class TestAsyncForLoop(object): '/bar', '', ] + + def test_bare_async(self, test_env_async): + t = test_env_async.from_string('{% extends "header" %}') + assert t.render(foo=42) == '[42|23]'