mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-10 06:31:57 +08:00
Some better message for tokenizing fails.
This commit is contained in:
@@ -513,15 +513,18 @@ class ErrorFinder(Normalizer):
|
|||||||
message = 'unindent does not match any outer indentation level'
|
message = 'unindent does not match any outer indentation level'
|
||||||
self._add_indentation_error(message, spacing)
|
self._add_indentation_error(message, spacing)
|
||||||
else:
|
else:
|
||||||
match = re.match('\\w{,2}("{1,3}|\'{1,3})', leaf.value)
|
if leaf.value.startswith('\\'):
|
||||||
if match is None:
|
message = 'unexpected character after line continuation character'
|
||||||
message = 'invalid syntax'
|
|
||||||
else:
|
else:
|
||||||
if len(match.group(1)) == 1:
|
match = re.match('\\w{,2}("{1,3}|\'{1,3})', leaf.value)
|
||||||
print(match.group(1))
|
if match is None:
|
||||||
message = 'EOL while scanning string literal'
|
message = 'invalid syntax'
|
||||||
else:
|
else:
|
||||||
message = 'EOF while scanning triple-quoted string literal'
|
if len(match.group(1)) == 1:
|
||||||
|
print(match.group(1))
|
||||||
|
message = 'EOL while scanning string literal'
|
||||||
|
else:
|
||||||
|
message = 'EOF while scanning triple-quoted string literal'
|
||||||
self._add_syntax_error(message, leaf, overwrite=True)
|
self._add_syntax_error(message, leaf, overwrite=True)
|
||||||
elif leaf.type == 'name':
|
elif leaf.type == 'name':
|
||||||
if leaf.value == '__debug__' and leaf.is_definition():
|
if leaf.value == '__debug__' and leaf.is_definition():
|
||||||
|
|||||||
@@ -111,6 +111,7 @@ FAILING_EXAMPLES = [
|
|||||||
r'"',
|
r'"',
|
||||||
r"'''",
|
r"'''",
|
||||||
r"'",
|
r"'",
|
||||||
|
r"\blub",
|
||||||
|
|
||||||
# SyntaxErrors from Python/symtable.c
|
# SyntaxErrors from Python/symtable.c
|
||||||
'def f(x, x): pass',
|
'def f(x, x): pass',
|
||||||
|
|||||||
Reference in New Issue
Block a user