Skip to content
Myr

Merge pull request #1613 from dairiki/bug.environment-not-pickleable

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

authored by David Lord · committed by GitHub · parents 09907ef, ac3ac6c · Browse files · 3 files+18 added−1 removed
This commit

State

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

Diff stats

3 files+18 added−1 removed

  • tests:+6 added−0 removed
  • other:+12 added−1 removed

3 files+18 added−1 removed

modified:src/jinja2/async_utils.py+10 added-1 removed
1import inspect2import typing as t3from functools import WRAPPER_ASSIGNMENTS4from functools import wraps56from .utils import _PassArg7from .utils import pass_eval_context
15 unmodified lines
2324 def is_async(args: t.Any) -> bool:25 return t.cast(bool, args[0].environment.is_async)2626 @wraps(normal_func)27 # Take the doc and annotations from the sync function, but the28 # name from the async function. Pallets-Sphinx-Themes29 # build_function_directive expects __wrapped__ to point to the30 # sync function.31 async_func_attrs = ("__module__", "__name__", "__qualname__")32 normal_func_attrs = tuple(set(WRAPPER_ASSIGNMENTS).difference(async_func_attrs))3334 @wraps(normal_func, assigned=normal_func_attrs)35 @wraps(async_func, assigned=async_func_attrs, updated=())36 def wrapper(*args, **kwargs): # type: ignore37 b = is_async(args)3839 if need_eval_context:
45 unmodified lines
added:tests/test_pickle.py+6 added
1import pickle234def test_environment(env):5 env = pickle.loads(pickle.dumps(env))6 assert env.from_string("x={{ x }}").render(x=42) == "x=42"
modified:CHANGES.rst+2 added
26 unmodified lines
27 passing a context string as the first token in the tag, like28 ``{% trans "title" %}``. :issue:`1430`29- Update valid identifier characters from Python 3.6 to 3.7.30 :pr:`1571`31- Filters and tests decorated with ``@async_variant`` are pickleable.32 :pr:`1612`333435Version 3.0.336-------------
911 unmodified lines