From 4468c3e4af05b2af04ab6241891ed545e7a2890a Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Sun, 24 Mar 2024 15:22:16 -0700 Subject: [PATCH] Bump mako from 1.2.4 to 1.3.2 (#2256) * Bump mako from 1.2.4 to 1.3.2 Bumps [mako](https://github.com/sqlalchemy/mako) from 1.2.4 to 1.3.2. - [Release notes](https://github.com/sqlalchemy/mako/releases) - [Changelog](https://github.com/sqlalchemy/mako/blob/main/CHANGES) - [Commits](https://github.com/sqlalchemy/mako/commits) --- updated-dependencies: - dependency-name: mako dependency-type: direct:production update-type: version-update:semver-minor ... Signed-off-by: dependabot[bot] * Update mako==1.3.2 --------- Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> Co-authored-by: JonnyWong16 <9099342+JonnyWong16@users.noreply.github.com> [skip ci] --- lib/mako/__init__.py | 4 ++-- lib/mako/_ast_util.py | 2 +- lib/mako/ast.py | 2 +- lib/mako/cache.py | 2 +- lib/mako/cmd.py | 3 +-- lib/mako/codegen.py | 4 +--- lib/mako/compat.py | 10 ++------ lib/mako/exceptions.py | 2 +- lib/mako/ext/autohandler.py | 2 +- lib/mako/ext/babelplugin.py | 2 +- lib/mako/ext/beaker_cache.py | 2 +- lib/mako/ext/extract.py | 2 +- lib/mako/ext/linguaplugin.py | 2 +- lib/mako/ext/preprocessors.py | 2 +- lib/mako/ext/pygmentplugin.py | 2 +- lib/mako/ext/turbogears.py | 2 +- lib/mako/filters.py | 2 +- lib/mako/lexer.py | 20 ++++++++++++---- lib/mako/lookup.py | 3 +-- lib/mako/parsetree.py | 2 +- lib/mako/pygen.py | 2 +- lib/mako/pyparser.py | 5 +--- lib/mako/runtime.py | 2 +- lib/mako/template.py | 3 +-- lib/mako/testing/assertions.py | 1 - lib/mako/testing/helpers.py | 4 ++++ lib/mako/util.py | 2 +- lib/markupsafe/__init__.py | 44 +++++++++++++++++++++++++++------- requirements.txt | 2 +- 29 files changed, 83 insertions(+), 54 deletions(-) diff --git a/lib/mako/__init__.py b/lib/mako/__init__.py index d7339219..d022cf82 100644 --- a/lib/mako/__init__.py +++ b/lib/mako/__init__.py @@ -1,8 +1,8 @@ # mako/__init__.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php -__version__ = "1.2.4" +__version__ = "1.3.2" diff --git a/lib/mako/_ast_util.py b/lib/mako/_ast_util.py index 95742835..63b8f228 100644 --- a/lib/mako/_ast_util.py +++ b/lib/mako/_ast_util.py @@ -1,5 +1,5 @@ # mako/_ast_util.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ast.py b/lib/mako/ast.py index a3f3ee3e..e59df3eb 100644 --- a/lib/mako/ast.py +++ b/lib/mako/ast.py @@ -1,5 +1,5 @@ # mako/ast.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/cache.py b/lib/mako/cache.py index db21bb3e..bad25257 100644 --- a/lib/mako/cache.py +++ b/lib/mako/cache.py @@ -1,5 +1,5 @@ # mako/cache.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/cmd.py b/lib/mako/cmd.py index 93a6733f..3858a127 100755 --- a/lib/mako/cmd.py +++ b/lib/mako/cmd.py @@ -1,5 +1,5 @@ # mako/cmd.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php @@ -25,7 +25,6 @@ def _exit(): def cmdline(argv=None): - parser = ArgumentParser() parser.add_argument( "--var", diff --git a/lib/mako/codegen.py b/lib/mako/codegen.py index d1d2c20a..ce6f83aa 100644 --- a/lib/mako/codegen.py +++ b/lib/mako/codegen.py @@ -1,5 +1,5 @@ # mako/codegen.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php @@ -816,7 +816,6 @@ class _GenerateRenderMethod: ) or len(self.compiler.default_filters) ): - s = self.create_filter_callable( node.escapes_code.args, "%s" % node.text, True ) @@ -1181,7 +1180,6 @@ class _Identifiers: def visitBlockTag(self, node): if node is not self.node and not node.is_anonymous: - if isinstance(self.node, parsetree.DefTag): raise exceptions.CompileException( "Named block '%s' not allowed inside of def '%s'" diff --git a/lib/mako/compat.py b/lib/mako/compat.py index 48df30d6..18322159 100644 --- a/lib/mako/compat.py +++ b/lib/mako/compat.py @@ -1,17 +1,17 @@ # mako/compat.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php import collections +from importlib import metadata as importlib_metadata from importlib import util import inspect import sys win32 = sys.platform.startswith("win") pypy = hasattr(sys, "pypy_version_info") -py38 = sys.version_info >= (3, 8) ArgSpec = collections.namedtuple( "ArgSpec", ["args", "varargs", "keywords", "defaults"] @@ -62,12 +62,6 @@ def exception_name(exc): return exc.__class__.__name__ -if py38: - from importlib import metadata as importlib_metadata -else: - import importlib_metadata # noqa - - def importlib_metadata_get(group): ep = importlib_metadata.entry_points() if hasattr(ep, "select"): diff --git a/lib/mako/exceptions.py b/lib/mako/exceptions.py index 31c695fd..ca225677 100644 --- a/lib/mako/exceptions.py +++ b/lib/mako/exceptions.py @@ -1,5 +1,5 @@ # mako/exceptions.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/autohandler.py b/lib/mako/ext/autohandler.py index 5bcfc285..dff9b6a8 100644 --- a/lib/mako/ext/autohandler.py +++ b/lib/mako/ext/autohandler.py @@ -1,5 +1,5 @@ # ext/autohandler.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/babelplugin.py b/lib/mako/ext/babelplugin.py index 907d0b80..cdb37cdf 100644 --- a/lib/mako/ext/babelplugin.py +++ b/lib/mako/ext/babelplugin.py @@ -1,5 +1,5 @@ # ext/babelplugin.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/beaker_cache.py b/lib/mako/ext/beaker_cache.py index 9aa35b06..590fbd01 100644 --- a/lib/mako/ext/beaker_cache.py +++ b/lib/mako/ext/beaker_cache.py @@ -1,5 +1,5 @@ # ext/beaker_cache.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/extract.py b/lib/mako/ext/extract.py index 9d33ee18..d03789db 100644 --- a/lib/mako/ext/extract.py +++ b/lib/mako/ext/extract.py @@ -1,5 +1,5 @@ # ext/extract.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/linguaplugin.py b/lib/mako/ext/linguaplugin.py index efb04c70..22077e66 100644 --- a/lib/mako/ext/linguaplugin.py +++ b/lib/mako/ext/linguaplugin.py @@ -1,5 +1,5 @@ # ext/linguaplugin.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/preprocessors.py b/lib/mako/ext/preprocessors.py index 80403ecd..6d1aaf5d 100644 --- a/lib/mako/ext/preprocessors.py +++ b/lib/mako/ext/preprocessors.py @@ -1,5 +1,5 @@ # ext/preprocessors.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/pygmentplugin.py b/lib/mako/ext/pygmentplugin.py index 9acbf4cd..f422623d 100644 --- a/lib/mako/ext/pygmentplugin.py +++ b/lib/mako/ext/pygmentplugin.py @@ -1,5 +1,5 @@ # ext/pygmentplugin.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/ext/turbogears.py b/lib/mako/ext/turbogears.py index 2ebf0746..2a3ec7d7 100644 --- a/lib/mako/ext/turbogears.py +++ b/lib/mako/ext/turbogears.py @@ -1,5 +1,5 @@ # ext/turbogears.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/filters.py b/lib/mako/filters.py index af202f3f..2a4b4386 100644 --- a/lib/mako/filters.py +++ b/lib/mako/filters.py @@ -1,5 +1,5 @@ # mako/filters.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/lexer.py b/lib/mako/lexer.py index 75182f85..9d1f5f30 100644 --- a/lib/mako/lexer.py +++ b/lib/mako/lexer.py @@ -1,5 +1,5 @@ # mako/lexer.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php @@ -247,6 +247,8 @@ class Lexer: continue if self.match_python_block(): continue + if self.match_percent(): + continue if self.match_text(): continue @@ -352,14 +354,24 @@ class Lexer: else: return True + def match_percent(self): + match = self.match(r"(?<=^)(\s*)%%(%*)", re.M) + if match: + self.append_node( + parsetree.Text, match.group(1) + "%" + match.group(2) + ) + return True + else: + return False + def match_text(self): match = self.match( r""" (.*?) # anything, followed by: ( - (?<=\n)(?=[ \t]*(?=%|\#\#)) # an eval or line-based - # comment preceded by a - # consumed newline and whitespace + (?<=\n)(?=[ \t]*(?=%|\#\#)) # an eval or line-based + # comment, preceded by a + # consumed newline and whitespace | (?=\${) # an expression | diff --git a/lib/mako/lookup.py b/lib/mako/lookup.py index f7410ce3..d916db77 100644 --- a/lib/mako/lookup.py +++ b/lib/mako/lookup.py @@ -1,5 +1,5 @@ # mako/lookup.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php @@ -178,7 +178,6 @@ class TemplateLookup(TemplateCollection): lexer_cls=None, include_error_handler=None, ): - self.directories = [ posixpath.normpath(d) for d in util.to_list(directories, ()) ] diff --git a/lib/mako/parsetree.py b/lib/mako/parsetree.py index c5a12d1d..04686ece 100644 --- a/lib/mako/parsetree.py +++ b/lib/mako/parsetree.py @@ -1,5 +1,5 @@ # mako/parsetree.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/pygen.py b/lib/mako/pygen.py index 57c69793..820e101d 100644 --- a/lib/mako/pygen.py +++ b/lib/mako/pygen.py @@ -1,5 +1,5 @@ # mako/pygen.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/mako/pyparser.py b/lib/mako/pyparser.py index d9b090c6..9b63dc33 100644 --- a/lib/mako/pyparser.py +++ b/lib/mako/pyparser.py @@ -1,5 +1,5 @@ # mako/pyparser.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php @@ -64,7 +64,6 @@ class FindIdentifiers(_ast_util.NodeVisitor): self._add_declared(node.name) def visit_Assign(self, node): - # flip around the visiting of Assign so the expression gets # evaluated first, in the case of a clause like "x=x+5" (x # is undeclared) @@ -99,7 +98,6 @@ class FindIdentifiers(_ast_util.NodeVisitor): yield arg def _visit_function(self, node, islambda): - # push function state onto stack. dont log any more # identifiers as "declared" until outside of the function, # but keep logging identifiers as "undeclared". track @@ -122,7 +120,6 @@ class FindIdentifiers(_ast_util.NodeVisitor): self.local_ident_stack = local_ident_stack def visit_For(self, node): - # flip around visit self.visit(node.iter) diff --git a/lib/mako/runtime.py b/lib/mako/runtime.py index 6d7fa684..23401b70 100644 --- a/lib/mako/runtime.py +++ b/lib/mako/runtime.py @@ -530,7 +530,7 @@ class Namespace: def _populate(self, d, l): for ident in l: if ident == "*": - for (k, v) in self._get_star(): + for k, v in self._get_star(): d[k] = v else: d[ident] = getattr(self, ident) diff --git a/lib/mako/template.py b/lib/mako/template.py index 8c70731d..e2771727 100644 --- a/lib/mako/template.py +++ b/lib/mako/template.py @@ -1,5 +1,5 @@ # mako/template.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php @@ -26,7 +26,6 @@ from mako.lexer import Lexer class Template: - r"""Represents a compiled template. :class:`.Template` includes a reference to the original diff --git a/lib/mako/testing/assertions.py b/lib/mako/testing/assertions.py index 14ea6352..22221cd2 100644 --- a/lib/mako/testing/assertions.py +++ b/lib/mako/testing/assertions.py @@ -103,7 +103,6 @@ def _assert_raises( check_context=False, cause_cls=None, ): - with _expect_raises(except_cls, msg, check_context, cause_cls) as ec: callable_(*args, **kwargs) return ec.error diff --git a/lib/mako/testing/helpers.py b/lib/mako/testing/helpers.py index 77cca367..5ae9d38d 100644 --- a/lib/mako/testing/helpers.py +++ b/lib/mako/testing/helpers.py @@ -19,6 +19,10 @@ def result_lines(result): ] +def result_raw_lines(result): + return [x for x in re.split(r"\r?\n", result) if x.strip() != ""] + + def make_path( filespec: Union[Path, str], make_absolute: bool = True, diff --git a/lib/mako/util.py b/lib/mako/util.py index 5fb683b4..91188cac 100644 --- a/lib/mako/util.py +++ b/lib/mako/util.py @@ -1,5 +1,5 @@ # mako/util.py -# Copyright 2006-2022 the Mako authors and contributors +# Copyright 2006-2024 the Mako authors and contributors # # This module is part of Mako and is released under # the MIT License: http://www.opensource.org/licenses/mit-license.php diff --git a/lib/markupsafe/__init__.py b/lib/markupsafe/__init__.py index 21d31960..b40f24c6 100644 --- a/lib/markupsafe/__init__.py +++ b/lib/markupsafe/__init__.py @@ -1,5 +1,4 @@ import functools -import re import string import sys import typing as t @@ -14,10 +13,7 @@ if t.TYPE_CHECKING: _P = te.ParamSpec("_P") -__version__ = "2.1.3" - -_strip_comments_re = re.compile(r"", re.DOTALL) -_strip_tags_re = re.compile(r"<.*?>", re.DOTALL) +__version__ = "2.1.5" def _simple_escaping_wrapper(func: "t.Callable[_P, str]") -> "t.Callable[_P, Markup]": @@ -162,9 +158,41 @@ class Markup(str): >>> Markup("Main »\tAbout").striptags() 'Main ยป About' """ - # Use two regexes to avoid ambiguous matches. - value = _strip_comments_re.sub("", self) - value = _strip_tags_re.sub("", value) + value = str(self) + + # Look for comments then tags separately. Otherwise, a comment that + # contains a tag would end early, leaving some of the comment behind. + + while True: + # keep finding comment start marks + start = value.find("", start) + + if end == -1: + break + + value = f"{value[:start]}{value[end + 3:]}" + + # remove tags using the same method + while True: + start = value.find("<") + + if start == -1: + break + + end = value.find(">", start) + + if end == -1: + break + + value = f"{value[:start]}{value[end + 1:]}" + + # collapse spaces value = " ".join(value.split()) return self.__class__(value).unescape() diff --git a/requirements.txt b/requirements.txt index 29f2c784..32bd430e 100644 --- a/requirements.txt +++ b/requirements.txt @@ -22,7 +22,7 @@ importlib-metadata==6.8.0 importlib-resources==6.0.1 git+https://github.com/Tautulli/ipwhois.git@master#egg=ipwhois IPy==1.01 -Mako==1.2.4 +Mako==1.3.2 MarkupSafe==2.1.3 musicbrainzngs==0.7.1 packaging==23.1