Error recovery should not match the whole line in case of an invalid token, fixes #40

This commit is contained in:
Dave Halter
2018-07-03 01:31:02 +02:00
parent 7f964c26f2
commit e05d7fd59f
3 changed files with 32 additions and 9 deletions

View File

@@ -448,16 +448,15 @@ def tokenize_lines(lines, version_info, start_pos=(1, 0)):
pseudomatch = pseudo_token.match(line, pos)
if not pseudomatch: # scan for tokens
if line.endswith('\n'):
new_line = True
match = whitespace.match(line, pos)
pos = match.end()
yield PythonToken(
ERRORTOKEN, line[pos:], (lnum, pos),
ERRORTOKEN, line[pos], (lnum, pos),
additional_prefix + match.group(0)
)
additional_prefix = ''
break
pos += 1
continue
prefix = additional_prefix + pseudomatch.group(1)
additional_prefix = ''