]> git.ipfire.org Git - thirdparty/jinja.git/commitdiff
Bugfix: wrong default argument for `Environment.overlay(enable_async)` parameter 2061/head
authorSamyCookie <SamyCookie@users.noreply.github.com>
Thu, 19 Dec 2024 09:59:57 +0000 (10:59 +0100)
committerDavid Lord <davidism@gmail.com>
Fri, 20 Dec 2024 02:22:32 +0000 (18:22 -0800)
CHANGES.rst
src/jinja2/environment.py
tests/test_api.py

index 0a569475733712d8e6b15f781c51972e43687d90..745b9690ac541942306fb15de329c10ac1fa1a0d 100644 (file)
@@ -31,6 +31,7 @@ Unreleased
     objects. :issue:`2025`
 -   Fix `copy`/`pickle` support for the internal ``missing`` object.
     :issue:`2027`
+-   ``Environment.overlay(enable_async)`` is applied correctly. :pr:`2061`
 
 
 Version 3.1.4
index f062e40740d44098aa5b1dcfeab1cde04c173cc6..821971779660e24001c5997236368fd878512f7a 100644 (file)
@@ -406,7 +406,7 @@ class Environment:
         cache_size: int = missing,
         auto_reload: bool = missing,
         bytecode_cache: t.Optional["BytecodeCache"] = missing,
-        enable_async: bool = False,
+        enable_async: bool = missing,
     ) -> "Environment":
         """Create a new overlay environment that shares all the data with the
         current environment except for cache and the overridden attributes.
@@ -419,8 +419,11 @@ class Environment:
         copied over so modifications on the original environment may not shine
         through.
 
+        .. versionchanged:: 3.1.5
+            ``enable_async`` is applied correctly.
+
         .. versionchanged:: 3.1.2
-            Added the ``newline_sequence``,, ``keep_trailing_newline``,
+            Added the ``newline_sequence``, ``keep_trailing_newline``,
             and ``enable_async`` parameters to match ``__init__``.
         """
         args = dict(locals())
index ee11a8d6951086c125e3913e24f5fdfa17e3ed67..4472b85ac00e9e34aa468c22505d5c53985da36d 100644 (file)
@@ -425,3 +425,11 @@ class TestLowLevel:
         env = CustomEnvironment()
         tmpl = env.from_string("{{ foo }}")
         assert tmpl.render() == "resolve-foo"
+
+
+def test_overlay_enable_async(env):
+    assert not env.is_async
+    assert not env.overlay().is_async
+    env_async = env.overlay(enable_async=True)
+    assert env_async.is_async
+    assert not env_async.overlay(enable_async=False).is_async