Skip to content
Myr

Merge pull request #617 from jackwilsdon/dont-skip-comma

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

Don't skip an erroneous comma when parsing "from"

authored by David Lord · committed by GitHub · parents a361b74, 8f46bec · Browse files · 3 files+8 added−2 removed
This commit

State

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

Diff stats

3 files+8 added−2 removed

  • tests:+6 added−0 removed
  • other:+2 added−2 removed

3 files+8 added−2 removed

modified:jinja2/parser.py-1 removed
335 unmodified lines
336 else:337 self.stream.expect('name')338 if not hasattr(node, 'with_context'):339 node.with_context = False340 self.stream.skip_if('comma')340 return node341342 def parse_signature(self, node):343 node.args = args = []
560 unmodified lines
modified:tests/test_imports.py+6 added
73 unmodified lines
74 test_env.from_string('{% from "foo" import bar, with context %}')75 test_env.from_string('{% from "foo" import bar, with, context %}')76 test_env.from_string('{% from "foo" import bar, with with context %}')7778 with pytest.raises(TemplateSyntaxError):79 test_env.from_string('{% from "foo" import bar,, with context %}')8081 with pytest.raises(TemplateSyntaxError):82 test_env.from_string('{% from "foo" import bar with context, %}')8384 def test_exports(self, test_env):85 m = test_env.from_string('''86 {% macro toplevel() %}...{% endmacro %}87 {% macro __private() %}...{% endmacro %}
93 unmodified lines
modified:CHANGES+2 added-1 removed
26 unmodified lines
27- Add a ``unique`` filter. (`#469`_)28- Add ``min`` and ``max`` filters. (`#475`_)29- Add tests for all comparison operators: ``eq``, ``ne``, ``lt``, ``le``,30 ``gt``, ``ge``. (`#665`_)31- ``import`` statement cannot end with a trailing comma. (`#618`_)31- ``import`` statement cannot end with a trailing comma. (`#617`_, `#618`_)3233.. _#469: https://github.com/pallets/jinja/pull/46934.. _#475: https://github.com/pallets/jinja/pull/47535.. _#478: https://github.com/pallets/jinja/pull/47836.. _#617: https://github.com/pallets/jinja/pull/61737.. _#618: https://github.com/pallets/jinja/pull/61838.. _#665: https://github.com/pallets/jinja/pull/6653940Version 2.9.6
506 unmodified lines