diff options
author | robot-contrib <robot-contrib@yandex-team.com> | 2024-01-25 09:51:43 +0300 |
---|---|---|
committer | Alexander Smirnov <alex@ydb.tech> | 2024-01-26 20:49:07 +0300 |
commit | 92337b2b7ff92e1f9fec1c01048366042b848998 (patch) | |
tree | 529a8d180a840df671c5ff57c27513913e41d83a /contrib/python/Jinja2/py3/jinja2/ext.py | |
parent | ccdd7d3aed84ad876ff5d2045b1f1cc5eedb9aea (diff) | |
download | ydb-92337b2b7ff92e1f9fec1c01048366042b848998.tar.gz |
Update contrib/python/Jinja2/py3 to 3.1.3
Diffstat (limited to 'contrib/python/Jinja2/py3/jinja2/ext.py')
-rw-r--r-- | contrib/python/Jinja2/py3/jinja2/ext.py | 20 |
1 files changed, 15 insertions, 5 deletions
diff --git a/contrib/python/Jinja2/py3/jinja2/ext.py b/contrib/python/Jinja2/py3/jinja2/ext.py index d5550540cda..fade1fa3bc8 100644 --- a/contrib/python/Jinja2/py3/jinja2/ext.py +++ b/contrib/python/Jinja2/py3/jinja2/ext.py @@ -291,14 +291,14 @@ class InternationalizationExtension(Extension): if hasattr(translations, "pgettext"): # Python < 3.8 - pgettext = translations.pgettext # type: ignore + pgettext = translations.pgettext else: def pgettext(c: str, s: str) -> str: return s if hasattr(translations, "npgettext"): - npgettext = translations.npgettext # type: ignore + npgettext = translations.npgettext else: def npgettext(c: str, s: str, p: str, n: int) -> str: @@ -495,16 +495,26 @@ class InternationalizationExtension(Extension): parser.stream.expect("variable_end") elif parser.stream.current.type == "block_begin": next(parser.stream) - if parser.stream.current.test("name:endtrans"): + block_name = ( + parser.stream.current.value + if parser.stream.current.type == "name" + else None + ) + if block_name == "endtrans": break - elif parser.stream.current.test("name:pluralize"): + elif block_name == "pluralize": if allow_pluralize: break parser.fail( "a translatable section can have only one pluralize section" ) + elif block_name == "trans": + parser.fail( + "trans blocks can't be nested; did you mean `endtrans`?" + ) parser.fail( - "control structures in translatable sections are not allowed" + f"control structures in translatable sections are not allowed; " + f"saw `{block_name}`" ) elif parser.stream.eos: parser.fail("unclosed translation block") |