Skip to content
Myr

Don't skip an erroneous comma when parsing from

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

Currently we skip an extra comma when "with context" is not provided to the "from" statement. This allows invalid code such as this: {% from "functions.html" import my_function,, %} The primary issue with this is that it is not consistent when providing "with context". The following code throws an error, contrary to the previous example: {% from "functions.html" import my_function,, with context %} It seems that the comma skipping was originally found in 0611e49 and was accidentally put inside the "with context" check in ea847c5. It was then updated to use "skip_if" in fdf9530. There doesn't seem to be any reason for this check existing, as double commas should never be allowed and serve no purpose in the statement.

authored by Jack Wilsdon · committed by David Lord · parent a361b74 · Browse files · 1 file+0 added−1 removed
This commit

State

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

Diff stats

1 file+0 added−1 removed

  • other:+0 added−1 removed

1 file+0 added−1 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