Browse Source

Update contrib/python/Jinja2/py3 to 3.1.3

robot-contrib 1 year ago
parent
commit
42db3295ba

+ 3 - 11
contrib/python/Jinja2/py3/.dist-info/METADATA

@@ -1,10 +1,8 @@
 Metadata-Version: 2.1
 Name: Jinja2
-Version: 3.1.2
+Version: 3.1.3
 Summary: A very fast and expressive template engine.
 Home-page: https://palletsprojects.com/p/jinja/
-Author: Armin Ronacher
-Author-email: armin.ronacher@active-4.com
 Maintainer: Pallets
 Maintainer-email: contact@palletsprojects.com
 License: BSD-3-Clause
@@ -13,9 +11,7 @@ Project-URL: Documentation, https://jinja.palletsprojects.com/
 Project-URL: Changes, https://jinja.palletsprojects.com/changes/
 Project-URL: Source Code, https://github.com/pallets/jinja/
 Project-URL: Issue Tracker, https://github.com/pallets/jinja/issues/
-Project-URL: Twitter, https://twitter.com/PalletsTeam
 Project-URL: Chat, https://discord.gg/pallets
-Platform: UNKNOWN
 Classifier: Development Status :: 5 - Production/Stable
 Classifier: Environment :: Web Environment
 Classifier: Intended Audience :: Developers
@@ -27,9 +23,9 @@ Classifier: Topic :: Text Processing :: Markup :: HTML
 Requires-Python: >=3.7
 Description-Content-Type: text/x-rst
 License-File: LICENSE.rst
-Requires-Dist: MarkupSafe (>=2.0)
+Requires-Dist: MarkupSafe >=2.0
 Provides-Extra: i18n
-Requires-Dist: Babel (>=2.7) ; extra == 'i18n'
+Requires-Dist: Babel >=2.7 ; extra == 'i18n'
 
 Jinja
 =====
@@ -106,8 +102,4 @@ Links
 -   PyPI Releases: https://pypi.org/project/Jinja2/
 -   Source Code: https://github.com/pallets/jinja/
 -   Issue Tracker: https://github.com/pallets/jinja/issues/
--   Website: https://palletsprojects.com/p/jinja/
--   Twitter: https://twitter.com/PalletsTeam
 -   Chat: https://discord.gg/pallets
-
-

+ 0 - 2
contrib/python/Jinja2/py3/README.rst

@@ -73,6 +73,4 @@ Links
 -   PyPI Releases: https://pypi.org/project/Jinja2/
 -   Source Code: https://github.com/pallets/jinja/
 -   Issue Tracker: https://github.com/pallets/jinja/issues/
--   Website: https://palletsprojects.com/p/jinja/
--   Twitter: https://twitter.com/PalletsTeam
 -   Chat: https://discord.gg/pallets

+ 1 - 1
contrib/python/Jinja2/py3/jinja2/__init__.py

@@ -35,4 +35,4 @@ from .utils import pass_environment as pass_environment
 from .utils import pass_eval_context as pass_eval_context
 from .utils import select_autoescape as select_autoescape
 
-__version__ = "3.1.2"
+__version__ = "3.1.3"

+ 1 - 1
contrib/python/Jinja2/py3/jinja2/async_utils.py

@@ -74,7 +74,7 @@ async def auto_aiter(
         async for item in t.cast("t.AsyncIterable[V]", iterable):
             yield item
     else:
-        for item in t.cast("t.Iterable[V]", iterable):
+        for item in iterable:
             yield item
 
 

+ 2 - 3
contrib/python/Jinja2/py3/jinja2/compiler.py

@@ -993,7 +993,6 @@ class CodeGenerator(NodeVisitor):
         # far, we don't have to add a check if something extended
         # the template before this one.
         if self.extends_so_far > 0:
-
             # if we have a known extends we just add a template runtime
             # error into the generated code.  We could catch that at compile
             # time too, but i welcome it not to confuse users by throwing the
@@ -1407,7 +1406,7 @@ class CodeGenerator(NodeVisitor):
 
             if pass_arg is None:
 
-                def finalize(value: t.Any) -> t.Any:
+                def finalize(value: t.Any) -> t.Any:  # noqa: F811
                     return default(env_finalize(value))
 
             else:
@@ -1415,7 +1414,7 @@ class CodeGenerator(NodeVisitor):
 
                 if pass_arg == "environment":
 
-                    def finalize(value: t.Any) -> t.Any:
+                    def finalize(value: t.Any) -> t.Any:  # noqa: F811
                         return default(env_finalize(self.environment, value))
 
         self._finalize = self._FinalizeInfo(finalize, src)

+ 6 - 6
contrib/python/Jinja2/py3/jinja2/environment.py

@@ -701,7 +701,7 @@ class Environment:
 
         .. versionadded:: 2.5
         """
-        return compile(source, filename, "exec")  # type: ignore
+        return compile(source, filename, "exec")
 
     @typing.overload
     def compile(  # type: ignore
@@ -920,7 +920,7 @@ class Environment:
                 )
 
             def filter_func(x: str) -> bool:
-                return "." in x and x.rsplit(".", 1)[1] in extensions  # type: ignore
+                return "." in x and x.rsplit(".", 1)[1] in extensions
 
         if filter_func is not None:
             names = [name for name in names if filter_func(name)]
@@ -1253,7 +1253,7 @@ class Template:
         t.blocks = namespace["blocks"]
 
         # render function and module
-        t.root_render_func = namespace["root"]  # type: ignore
+        t.root_render_func = namespace["root"]
         t._module = None
 
         # debug and loader helpers
@@ -1349,7 +1349,7 @@ class Template:
         ctx = self.new_context(dict(*args, **kwargs))
 
         try:
-            yield from self.root_render_func(ctx)  # type: ignore
+            yield from self.root_render_func(ctx)
         except Exception:
             yield self.environment.handle_exception()
 
@@ -1532,7 +1532,7 @@ class TemplateModule:
                     " API you are using."
                 )
 
-            body_stream = list(template.root_render_func(context))  # type: ignore
+            body_stream = list(template.root_render_func(context))
 
         self._body_stream = body_stream
         self.__dict__.update(context.get_exported())
@@ -1564,7 +1564,7 @@ class TemplateExpression:
 
     def __call__(self, *args: t.Any, **kwargs: t.Any) -> t.Optional[t.Any]:
         context = self._template.new_context(dict(*args, **kwargs))
-        consume(self._template.root_render_func(context))  # type: ignore
+        consume(self._template.root_render_func(context))
         rv = context.vars["result"]
         if self._undefined_to_none and isinstance(rv, Undefined):
             rv = None

+ 15 - 5
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")

+ 21 - 7
contrib/python/Jinja2/py3/jinja2/filters.py

@@ -248,13 +248,17 @@ def do_items(value: t.Union[t.Mapping[K, V], Undefined]) -> t.Iterator[t.Tuple[K
     yield from value.items()
 
 
+_space_re = re.compile(r"\s", flags=re.ASCII)
+
+
 @pass_eval_context
 def do_xmlattr(
     eval_ctx: "EvalContext", d: t.Mapping[str, t.Any], autospace: bool = True
 ) -> str:
     """Create an SGML/XML attribute string based on the items in a dict.
-    All values that are neither `none` nor `undefined` are automatically
-    escaped:
+
+    If any key contains a space, this fails with a ``ValueError``. Values that
+    are neither ``none`` nor ``undefined`` are automatically escaped.
 
     .. sourcecode:: html+jinja
 
@@ -273,12 +277,22 @@ def do_xmlattr(
 
     As you can see it automatically prepends a space in front of the item
     if the filter returned something unless the second parameter is false.
+
+    .. versionchanged:: 3.1.3
+        Keys with spaces are not allowed.
     """
-    rv = " ".join(
-        f'{escape(key)}="{escape(value)}"'
-        for key, value in d.items()
-        if value is not None and not isinstance(value, Undefined)
-    )
+    items = []
+
+    for key, value in d.items():
+        if value is None or isinstance(value, Undefined):
+            continue
+
+        if _space_re.search(key) is not None:
+            raise ValueError(f"Spaces are not allowed in attributes: '{key}'")
+
+        items.append(f'{escape(key)}="{escape(value)}"')
+
+    rv = " ".join(items)
 
     if autospace and rv:
         rv = " " + rv

+ 18 - 18
contrib/python/Jinja2/py3/jinja2/loaders.py

@@ -16,7 +16,6 @@ from types import ModuleType
 
 from .exceptions import TemplateNotFound
 from .utils import internalcode
-from .utils import open_if_exists
 
 if t.TYPE_CHECKING:
     from .environment import Environment
@@ -196,29 +195,30 @@ class FileSystemLoader(BaseLoader):
         self, environment: "Environment", template: str
     ) -> t.Tuple[str, str, t.Callable[[], bool]]:
         pieces = split_template_path(template)
+
         for searchpath in self.searchpath:
             # Use posixpath even on Windows to avoid "drive:" or UNC
             # segments breaking out of the search directory.
             filename = posixpath.join(searchpath, *pieces)
-            f = open_if_exists(filename)
-            if f is None:
-                continue
-            try:
-                contents = f.read().decode(self.encoding)
-            finally:
-                f.close()
 
-            mtime = os.path.getmtime(filename)
+            if os.path.isfile(filename):
+                break
+        else:
+            raise TemplateNotFound(template)
 
-            def uptodate() -> bool:
-                try:
-                    return os.path.getmtime(filename) == mtime
-                except OSError:
-                    return False
+        with open(filename, encoding=self.encoding) as f:
+            contents = f.read()
 
-            # Use normpath to convert Windows altsep to sep.
-            return contents, os.path.normpath(filename), uptodate
-        raise TemplateNotFound(template)
+        mtime = os.path.getmtime(filename)
+
+        def uptodate() -> bool:
+            try:
+                return os.path.getmtime(filename) == mtime
+            except OSError:
+                return False
+
+        # Use normpath to convert Windows altsep to sep.
+        return contents, os.path.normpath(filename), uptodate
 
     def list_templates(self) -> t.List[str]:
         found = set()
@@ -412,7 +412,7 @@ class PackageLoader(BaseLoader):
             )
             offset = len(prefix)
 
-            for name in self._loader._files.keys():  # type: ignore
+            for name in self._loader._files.keys():
                 # Find names under the templates directory that aren't directories.
                 if name.startswith(prefix) and name[-1] != os.path.sep:
                     results.append(name[offset:].replace(os.path.sep, "/"))

+ 1 - 1
contrib/python/Jinja2/py3/jinja2/nativetypes.py

@@ -106,7 +106,7 @@ class NativeTemplate(Template):
 
         try:
             return self.environment_class.concat(  # type: ignore
-                self.root_render_func(ctx)  # type: ignore
+                self.root_render_func(ctx)
             )
         except Exception:
             return self.environment.handle_exception()

Some files were not shown because too many files changed in this diff