Skip to content
Myr

Add async flags

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Armin Ronacher · committed by Armin Ronacher · parent 4fa3712 · Browse files · 2 files+19 added−3 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

2 files+19 added−3 removed

  • other:+19 added−3 removed

2 files+19 added−3 removed

modified:jinja2/compiler.py+7 added
45 unmodified lines
46 code_features.append('generator_stop')47except SyntaxError:48 pass4950# does this python version support async for in and async generators?51try:52 exec('async def _():\n async for _ in ():\n yield _')53 have_async_gen = True54except SyntaxError:55 have_async_gen = False565758# does if 0: dummy(x) get us x into the scope?59def unoptimize_before_dead_code():60 x = 4261 def f():
1641 unmodified lines
modified:jinja2/environment.py+12 added-3 removed
215 unmodified lines
216 cache for the internal Jinja bytecode so that templates don't217 have to be parsed if they were not changed.218219 See :ref:`bytecode-cache` for more information.220221 `enable_async`222 If set to true this enables async template execution which allows223 you to take advantage of newer Python features. This requires224 Python 3.6 or later.225 """226227 #: if this environment is sandboxed. Modifying this variable won't make228 #: the environment sandboxed though. For a real sandboxed environment
43 unmodified lines
272 autoescape=False,273 loader=None,274 cache_size=400,275 auto_reload=True,271 bytecode_cache=None):276 bytecode_cache=None,277 enable_async=False):278 # !!Important notice!!279 # The constructor accepts quite a few arguments that should be280 # passed by keyword rather than position. However it's important to281 # not change the order of arguments because it's used at least
37 unmodified lines
319320 # load extensions321 self.extensions = load_extensions(self, extensions)322323 self.enable_async = enable_async324325 _environment_sanity_check(self)326327 def add_extension(self, extension):328 """Adds an extension after the environment was created.
586 unmodified lines
915 extensions=(),916 optimized=True,917 undefined=Undefined,918 finalize=None,911 autoescape=False):919 autoescape=False,920 enable_async=False):921 env = get_spontaneous_environment(922 block_start_string, block_end_string, variable_start_string,923 variable_end_string, comment_start_string, comment_end_string,924 line_statement_prefix, line_comment_prefix, trim_blocks,925 lstrip_blocks, newline_sequence, keep_trailing_newline,926 frozenset(extensions), optimized, undefined, finalize, autoescape,918 None, 0, False, None)927 None, 0, False, None, enable_async)928 return env.from_string(source, template_class=cls)929930 @classmethod931 def from_code(cls, environment, code, globals, uptodate=None):
284 unmodified lines