Skip to content
Myr

Merge branch '3.0.x'

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

authored by David Lord · committed by David Lord · parents 647677d, fb9cac6 · Browse files · 14 files+88 added−83 removed
This commit

State

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

Diff stats

14 files+88 added−83 removed

  • other:+88 added−83 removed

14 files+88 added−83 removed

modified:docs/extensions.rst+1 added-1 removed
121 unmodified lines
122The usage of the ``i18n`` extension for template designers is covered in123:ref:`the template documentation <i18n-in-templates>`.124125.. _gettext: https://docs.python.org/3/library/gettext.html126.. _Babel: http://babel.pocoo.org/126.. _Babel: https://babel.pocoo.org/127128129Whitespace Trimming130~~~~~~~~~~~~~~~~~~~
293 unmodified lines
modified:docs/intro.rst+1 added-1 removed
58 unmodified lines
59These distributions will not be installed automatically.6061- `Babel`_ provides translation support in templates.6263.. _Babel: http://babel.pocoo.org/63.. _Babel: https://babel.pocoo.org/
modified:docs/make.bat+1 added-1 removed
19 unmodified lines
20 echo.to the full path of the 'sphinx-build' executable. Alternatively you21 echo.may add the Sphinx directory to PATH.22 echo.23 echo.If you don't have Sphinx installed, grab it from24 echo.http://sphinx-doc.org/24 echo.https://www.sphinx-doc.org/25 exit /b 126)2728%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
7 unmodified lines
modified:requirements/dev.txt+33 added-30 removed
4 unmodified lines
5# pip-compile requirements/dev.in6#7alabaster==0.7.128 # via sphinx9appdirs==1.4.410 # via virtualenv9attrs==21.2.010 # via pytest11babel==2.9.112 # via sphinx13backports.entry-points-selectable==1.1.014 # via virtualenv15certifi==2020.12.515certifi==2021.5.3016 # via requests17cfgv==3.3.017cfgv==3.3.118 # via pre-commit19chardet==4.0.019charset-normalizer==2.0.620 # via requests21click==8.0.122 # via pip-tools23distlib==0.3.123distlib==0.3.324 # via virtualenv25docutils==0.17.126 # via sphinx27filelock==3.0.1227filelock==3.3.028 # via29 # tox30 # virtualenv31identify==2.2.431identify==2.3.032 # via pre-commit33idna==2.1033idna==3.234 # via requests35imagesize==1.2.036 # via sphinx37iniconfig==1.1.1
1 unmodified line
39jinja2==3.0.140 # via sphinx41markupsafe==2.0.142 # via jinja243mypy==0.91044 # via -r requirements/typing.in43mypy-extensions==0.4.344 # via mypy45mypy==0.91046 # via -r requirements/typing.in47nodeenv==1.6.048 # via pre-commit49packaging==20.949packaging==21.050 # via51 # pallets-sphinx-themes52 # pytest53 # sphinx54 # tox55pallets-sphinx-themes==2.0.156 # via -r requirements/docs.in57pep517==0.10.057pep517==0.11.058 # via pip-tools59pip-tools==6.2.059pip-tools==6.3.060 # via -r requirements/dev.in61pluggy==0.13.161platformdirs==2.4.062 # via virtualenv63pluggy==1.0.064 # via65 # pytest66 # tox65pre-commit==2.14.167pre-commit==2.15.068 # via -r requirements/dev.in69py==1.10.070 # via71 # pytest72 # tox71pygments==2.9.073pygments==2.10.074 # via sphinx75pyparsing==2.4.776 # via packaging77pytest==6.2.578 # via -r requirements/tests.in77pytz==2021.179pytz==2021.380 # via babel81pyyaml==5.4.182 # via pre-commit81requests==2.25.183requests==2.26.084 # via sphinx85six==1.16.086 # via87 # tox88 # virtualenv89snowballstemmer==2.1.090 # via sphinx89sphinx==4.0.291sphinx-issues==1.2.092 # via -r requirements/docs.in93sphinx==4.2.094 # via95 # -r requirements/docs.in96 # pallets-sphinx-themes97 # sphinx-issues98 # sphinxcontrib-log-cabinet95sphinx-issues==1.2.096 # via -r requirements/docs.in99sphinxcontrib-applehelp==1.0.2100 # via sphinx101sphinxcontrib-devhelp==1.0.2102 # via sphinx101sphinxcontrib-htmlhelp==1.0.3103sphinxcontrib-htmlhelp==2.0.0104 # via sphinx105sphinxcontrib-jsmath==1.0.1106 # via sphinx107sphinxcontrib-log-cabinet==1.0.1108 # via -r requirements/docs.in109sphinxcontrib-qthelp==1.0.3110 # via sphinx109sphinxcontrib-serializinghtml==1.1.4111sphinxcontrib-serializinghtml==1.1.5112 # via sphinx113toml==0.10.2114 # via115 # mypy114 # pep517116 # pre-commit117 # pytest118 # tox119tomli==1.2.1120 # via pep517118tox==3.24.3121tox==3.24.4122 # via -r requirements/dev.in120typing-extensions==3.10.0.0123typing-extensions==3.10.0.2124 # via mypy122urllib3==1.26.4125urllib3==1.26.7126 # via requests124virtualenv==20.4.6127virtualenv==20.8.1128 # via129 # pre-commit130 # tox128wheel==0.36.2131wheel==0.37.0132 # via pip-tools133134# The following packages are considered to be unsafe in a requirements file:135# pip
1 unmodified line
modified:requirements/docs.txt+11 added-11 removed
6 unmodified lines
7alabaster==0.7.128 # via sphinx9babel==2.9.110 # via sphinx11certifi==2020.12.511certifi==2021.5.3012 # via requests13chardet==4.0.013charset-normalizer==2.0.614 # via requests15docutils==0.17.116 # via sphinx17idna==2.1017idna==3.218 # via requests19imagesize==1.2.020 # via sphinx21jinja2==3.0.122 # via sphinx23markupsafe==2.0.124 # via jinja225packaging==20.925packaging==21.026 # via27 # pallets-sphinx-themes28 # sphinx29pallets-sphinx-themes==2.0.130 # via -r requirements/docs.in31pygments==2.9.031pygments==2.10.032 # via sphinx33pyparsing==2.4.734 # via packaging35pytz==2021.135pytz==2021.336 # via babel37requests==2.25.137requests==2.26.038 # via sphinx39snowballstemmer==2.1.040 # via sphinx41sphinx-issues==1.2.042 # via -r requirements/docs.in43sphinx==4.0.243sphinx==4.2.044 # via45 # -r requirements/docs.in46 # pallets-sphinx-themes47 # sphinx-issues
1 unmodified line
49sphinxcontrib-applehelp==1.0.250 # via sphinx51sphinxcontrib-devhelp==1.0.252 # via sphinx53sphinxcontrib-htmlhelp==1.0.353sphinxcontrib-htmlhelp==2.0.054 # via sphinx55sphinxcontrib-jsmath==1.0.156 # via sphinx57sphinxcontrib-log-cabinet==1.0.158 # via -r requirements/docs.in59sphinxcontrib-qthelp==1.0.360 # via sphinx61sphinxcontrib-serializinghtml==1.1.461sphinxcontrib-serializinghtml==1.1.562 # via sphinx63urllib3==1.26.463urllib3==1.26.764 # via requests6566# The following packages are considered to be unsafe in a requirements file:67# setuptools
modified:requirements/tests.txt+2 added-2 removed
6 unmodified lines
7attrs==21.2.08 # via pytest9iniconfig==1.1.110 # via pytest11packaging==20.911packaging==21.012 # via pytest13pluggy==0.13.113pluggy==1.0.014 # via pytest15py==1.10.016 # via pytest17pyparsing==2.4.7
5 unmodified lines
modified:requirements/typing.txt+3 added-3 removed
2 unmodified lines
3# To update, run:4#5# pip-compile requirements/typing.in6#7mypy==0.9108 # via -r requirements/typing.in7mypy-extensions==0.4.38 # via mypy9mypy==0.91010 # via -r requirements/typing.in11toml==0.10.212 # via mypy13typing-extensions==3.10.0.013typing-extensions==3.10.0.214 # via mypy
modified:src/jinja2/filters.py+4 added-4 removed
1348 unmodified lines
1349 try:1350 rv = list(value)1351 rv.reverse()1352 return rv1353 except TypeError:1354 raise FilterArgumentError("argument must be iterable")1353 except TypeError as e:1354 raise FilterArgumentError("argument must be iterable") from e135513561357@pass_environment1358def do_attr(
331 unmodified lines
1690 try:1691 name = args[0]1692 args = args[1:]1693 except LookupError:1694 raise FilterArgumentError("map requires a filter argument")1694 raise FilterArgumentError("map requires a filter argument") from None16951696 def func(item: t.Any) -> t.Any:1697 return context.environment.call_filter(1698 name, item, args, kwargs, context=context
12 unmodified lines
1711 if lookup_attr:1712 try:1713 attr = args[0]1714 except LookupError:1715 raise FilterArgumentError("Missing parameter for attribute name")1715 raise FilterArgumentError("Missing parameter for attribute name") from None17161717 transfunc = make_attrgetter(context.environment, attr)1718 off = 11719 else:
105 unmodified lines
modified:src/jinja2/lexer.py+1 added-1 removed
653 unmodified lines
654 .decode("unicode-escape")655 )656 except Exception as e:657 msg = str(e).split(":")[-1].strip()658 raise TemplateSyntaxError(msg, lineno, name, filename)658 raise TemplateSyntaxError(msg, lineno, name, filename) from e659 elif token == TOKEN_INTEGER:660 value = int(value_str.replace("_", ""), 0)661 elif token == TOKEN_FLOAT:662 # remove all "_" first to support more Python versions
207 unmodified lines
modified:src/jinja2/loaders.py+10 added-10 removed
334 unmodified lines
335 else:336 # Package is a zip file.337 try:338 source = self._loader.get_data(p) # type: ignore339 except OSError:340 raise TemplateNotFound(template)339 except OSError as e:340 raise TemplateNotFound(template) from e341342 # Could use the zip's mtime for all template mtimes, but343 # would need to safely reload the module if it's out of344 # date, so just report it as always current.
130 unmodified lines
475 def get_loader(self, template: str) -> t.Tuple[BaseLoader, str]:476 try:477 prefix, name = template.split(self.delimiter, 1)478 loader = self.mapping[prefix]479 except (ValueError, KeyError):480 raise TemplateNotFound(template)479 except (ValueError, KeyError) as e:480 raise TemplateNotFound(template) from e481 return loader, name482483 def get_source(484 self, environment: "Environment", template: str485 ) -> t.Tuple[str, t.Optional[str], t.Optional[t.Callable[[], bool]]]:486 loader, name = self.get_loader(template)487 try:488 return loader.get_source(environment, name)489 except TemplateNotFound:489 except TemplateNotFound as e:490 # re-raise the exception with the correct filename here.491 # (the one that includes the prefix)492 raise TemplateNotFound(template)492 raise TemplateNotFound(template) from e493494 @internalcode495 def load(496 self,
3 unmodified lines
500 ) -> "Template":501 loader, local_name = self.get_loader(name)502 try:503 return loader.load(environment, local_name, globals)504 except TemplateNotFound:504 except TemplateNotFound as e:505 # re-raise the exception with the correct filename here.506 # (the one that includes the prefix)507 raise TemplateNotFound(name)507 raise TemplateNotFound(name) from e508509 def list_templates(self) -> t.List[str]:510 result = []511 for prefix, loader in self.mapping.items():
114 unmodified lines
626627 if mod is None:628 try:629 mod = __import__(module, None, None, ["root"])630 except ImportError:631 raise TemplateNotFound(name)630 except ImportError as e:631 raise TemplateNotFound(name) from e632633 # remove the entry from sys.modules, we only want the attribute634 # on the module object we have stored on the loader.635 sys.modules.pop(module, None)
7 unmodified lines
modified:src/jinja2/nodes.py+16 added-16 removed
505 unmodified lines
506 raise Impossible()507 f = _binop_to_func[self.operator]508 try:509 return f(self.left.as_const(eval_ctx), self.right.as_const(eval_ctx))510 except Exception:511 raise Impossible()510 except Exception as e:511 raise Impossible() from e512513514class UnaryExpr(Expr):515 """Baseclass for all unary expressions."""
14 unmodified lines
530 raise Impossible()531 f = _uaop_to_func[self.operator]532 try:533 return f(self.node.as_const(eval_ctx))534 except Exception:535 raise Impossible()534 except Exception as e:535 raise Impossible() from e536537538class Name(Expr):539 """Looks up a name or stores a value in a name.
182 unmodified lines
722723 if node.dyn_args is not None:724 try:725 args.extend(node.dyn_args.as_const(eval_ctx))726 except Exception:727 raise Impossible()726 except Exception as e:727 raise Impossible() from e728729 if node.dyn_kwargs is not None:730 try:731 kwargs.update(node.dyn_kwargs.as_const(eval_ctx))732 except Exception:733 raise Impossible()732 except Exception as e:733 raise Impossible() from e734735 return args, kwargs736737
40 unmodified lines
778 args.insert(0, eval_ctx.environment)779780 try:781 return func(*args, **kwargs)782 except Exception:783 raise Impossible()782 except Exception as e:783 raise Impossible() from e784785786class Filter(_FilterTestCommon):787 """Apply a filter to an expression. ``name`` is the name of the
58 unmodified lines
846 try:847 return eval_ctx.environment.getitem(848 self.node.as_const(eval_ctx), self.arg.as_const(eval_ctx)849 )850 except Exception:851 raise Impossible()850 except Exception as e:851 raise Impossible() from e852853854class Getattr(Expr):855 """Get an attribute or item from an expression that is a ascii-only
12 unmodified lines
868 eval_ctx = get_eval_context(self, eval_ctx)869870 try:871 return eval_ctx.environment.getattr(self.node.as_const(eval_ctx), self.attr)872 except Exception:873 raise Impossible()872 except Exception as e:873 raise Impossible() from e874875876class Slice(Expr):877 """Represents a slice object. This must only be used as argument for
50 unmodified lines
928 if not result:929 return False930931 value = new_value932 except Exception:933 raise Impossible()932 except Exception as e:933 raise Impossible() from e934935 return result936937
268 unmodified lines
modified:src/jinja2/utils.py+1 added-1 removed
822 unmodified lines
823 return object.__getattribute__(self, name)824 try:825 return self.__attrs[name]826 except KeyError:827 raise AttributeError(name)827 raise AttributeError(name) from None828829 def __setitem__(self, name: str, value: t.Any) -> None:830 self.__attrs[name] = value831
23 unmodified lines
modified:.pre-commit-config.yaml+2 added-2 removed
1ci:2 autoupdate_schedule: monthly3repos:4 - repo: https://github.com/asottile/pyupgrade5 rev: v2.25.05 rev: v2.29.06 hooks:7 - id: pyupgrade8 args: ["--py36-plus"]9 - repo: https://github.com/asottile/reorder_python_imports
1 unmodified line
11 hooks:12 - id: reorder-python-imports13 args: ["--application-directories", "src"]14 - repo: https://github.com/psf/black15 rev: 21.8b015 rev: 21.9b016 hooks:17 - id: black18 - repo: https://github.com/PyCQA/flake819 rev: 3.9.2
9 unmodified lines
modified:setup.cfg+2 added
45 unmodified lines
46[tool:pytest]47testpaths = tests48filterwarnings =49 error50 # Python 3.9 raises a deprecation from internal asyncio code.51 ignore:The loop argument:DeprecationWarning:asyncio[.]base_events:5425253[coverage:run]54branch = True55source =
53 unmodified lines