Skip to content

Commit

Permalink
Merge pull request #229 from Yelp/weird_parsing_malformed_def
Browse files Browse the repository at this point in the history
Correctly error on weird def.  Resolves #228
  • Loading branch information
asottile committed Jun 2, 2016
2 parents 8f0534a + e05fc6a commit 6e0f4dd
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 1 deletion.
2 changes: 1 addition & 1 deletion Cheetah/legacy_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def getDefArgList(self):
" was found for the '('")

c = self.peek()
if c == ")" or self.matchDirectiveEndToken():
if c == ')':
break
elif c in " \t\r\n":
if onDefVal:
Expand Down
18 changes: 18 additions & 0 deletions tests/Parser_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -579,3 +579,21 @@ def test_errors_on_blinged_kwarg():
compile_to_class(
'$foo($bar=$baz)'
)


def test_weird_parsing():
with assert_raises_exactly(
ParseError,
'\n\n'
'Unexpected character.\n'
'Line 1, column 12\n\n'
'Line|Cheetah Code\n'
'----|-------------------------------------------------------------\n'
'1 |#def foo(x,#\n'
' ^\n'
'2 |#end def\n'
):
compile_to_class(
'#def foo(x,#\n'
'#end def\n'
)

0 comments on commit 6e0f4dd

Please sign in to comment.