Resolved extends errors in async mode (Fixes #668)
diff --git a/CHANGES b/CHANGES
index faa319c..be33089 100644
--- a/CHANGES
+++ b/CHANGES
@@ -13,6 +13,8 @@
- 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 0765675..b2ab6fe 100644
--- a/jinja2/compiler.py
+++ b/jinja2/compiler.py
@@ -734,12 +734,13 @@
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 bd3ef50..8618d8d 100644
--- a/tests/test_async.py
+++ b/tests/test_async.py
@@ -464,3 +464,7 @@
'<url><loc>/bar</loc></url>',
'</urlset>',
]
+
+ def test_bare_async(self, test_env_async):
+ t = test_env_async.from_string('{% extends "header" %}')
+ assert t.render(foo=42) == '[42|23]'