diff --git a/doc/build/changelog.rst b/doc/build/changelog.rst index 23d362a9..bf954f21 100644 --- a/doc/build/changelog.rst +++ b/doc/build/changelog.rst @@ -11,11 +11,11 @@ Changelog :include_notes_from: unreleased .. changelog:: - :version: 1.3.4 + :version: 1.3.4 (yanked) :released: Mon May 13 2024 .. change:: - :tags: bug, parser + :tags: bug, lexer :tickets: 398 Fixed regression caused by the fix for :ticket:`320` where new logic added @@ -31,6 +31,9 @@ Changelog dictionary literals, would fail to be interpreted correctly even though the initial parsing is correct. Pull request courtesy Jose Galvez. + .. note:: this change was **reverted** and release 1.3.4 was yanked as + this fix caused regressions. + .. changelog:: :version: 1.3.3 :released: Wed Apr 10 2024 diff --git a/doc/build/unreleased/400.rst b/doc/build/unreleased/400.rst new file mode 100644 index 00000000..2c98fdf4 --- /dev/null +++ b/doc/build/unreleased/400.rst @@ -0,0 +1,7 @@ +.. change:: + :tags: bug, lexer, regression + :tickets: 400, 401 + + Reverted the fix for :ticket:`400` as it caused new issues when traversing + some bracketed situations. + diff --git a/mako/parsetree.py b/mako/parsetree.py index dae707c1..04686ece 100644 --- a/mako/parsetree.py +++ b/mako/parsetree.py @@ -322,10 +322,10 @@ def _parse_attributes(self, expressions, nonexpressions): for key in self.attributes: if key in expressions: expr = [] - for x in re.compile(r"(\${.+})", re.S).split( + for x in re.compile(r"(\${.+?})", re.S).split( self.attributes[key] ): - m = re.compile(r"^\${(.+)}$", re.S).match(x) + m = re.compile(r"^\${(.+?)}$", re.S).match(x) if m: code = ast.PythonCode( m.group(1).rstrip(), **self.exception_kwargs diff --git a/test/test_lexer.py b/test/test_lexer.py index b1a796cd..d8029a17 100644 --- a/test/test_lexer.py +++ b/test/test_lexer.py @@ -810,7 +810,25 @@ def test_tricky_expression(self): ), ) - def test_dict_expression(self): + def test_dict_expression_issue_400_regression(self): + """test for issue #401. + + This was the regression case for #400 + + """ + template = '<%include file="${foo}${bar}"/>' + + nodes = Lexer(template).parse() + self._compare( + nodes, + TemplateNode( + {}, + [IncludeTag("include", {"file": "${foo}${bar}"}, (1, 1), [])], + ), + ) + + def _dont_test_dict_expression_issue_400(self): + """test for issue #400""" template = """ <%def name="dtest(d)"> % for k,v in d.items(): @@ -868,7 +886,8 @@ def test_dict_expression(self): ), ) - def test_dict_expression_2(self): + def _dont_test_dict_expression_2_issue_400(self): + """test for issue #400""" template = """ <%def name="thing(thing)"> ${type(thing)}