mirror of
https://github.com/davidhalter/jedi.git
synced 2025-12-08 06:44:46 +08:00
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
|
||||
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:
|
||||
return None, tok
|
||||
|
||||
@@ -119,3 +119,9 @@ def test_carriage_return_statements():
|
||||
source = source.replace('\n', '\r\n')
|
||||
stmt = Parser(source).module.statements[0]
|
||||
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