forked from VimPlug/jedi
another parser issue, very much related to the last one. sometimes a None element was used as a token.fixes #418
This commit is contained in:
@@ -1073,7 +1073,8 @@ isinstance(c, (tokenize.Token, Operator)) else unicode(c)
|
|||||||
end_pos = end_pos[0], end_pos[1] - 1
|
end_pos = end_pos[0], end_pos[1] - 1
|
||||||
break
|
break
|
||||||
|
|
||||||
token_list.append(tok)
|
if tok is not None: # Can be None, because of lambda/for.
|
||||||
|
token_list.append(tok)
|
||||||
|
|
||||||
if not token_list:
|
if not token_list:
|
||||||
return None, tok
|
return None, tok
|
||||||
|
|||||||
@@ -119,3 +119,9 @@ def test_carriage_return_statements():
|
|||||||
source = source.replace('\n', '\r\n')
|
source = source.replace('\n', '\r\n')
|
||||||
stmt = Parser(source).module.statements[0]
|
stmt = Parser(source).module.statements[0]
|
||||||
assert '#' not in stmt.get_code()
|
assert '#' not in stmt.get_code()
|
||||||
|
|
||||||
|
|
||||||
|
def test_incomplete_list_comprehension():
|
||||||
|
""" Shouldn't raise an error, same bug as #418. """
|
||||||
|
s = Parser(u('(1 for def')).module.statements[0]
|
||||||
|
assert s.expression_list()
|
||||||
|
|||||||
Reference in New Issue
Block a user