Skip to content

Commit d068243

Browse files
committed
Fix parser crash on parse error
Fixed #588.
1 parent b59bc5c commit d068243

File tree

2 files changed

+6
-1
lines changed

2 files changed

+6
-1
lines changed

mypy/parse.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1640,7 +1640,7 @@ def token_repr(tok: Token) -> str:
16401640
return '"{}"'.format(tok.string)
16411641
elif isinstance(tok, IntLit) or isinstance(tok, FloatLit) or isinstance(tok, ComplexLit):
16421642
return 'numeric literal'
1643-
elif isinstance(tok, StrLit):
1643+
elif isinstance(tok, StrLit) or isinstance(tok, UnicodeLit):
16441644
return 'string literal'
16451645
elif (isinstance(tok, Punct) or isinstance(tok, Op)
16461646
or isinstance(tok, Colon)):

mypy/test/data/parse-errors.test

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -402,3 +402,8 @@ from __future__ import *
402402
x = 1
403403
[out]
404404
file, line 1: Parse error before *
405+
406+
[case testParseErrorBeforeUnicodeLiteral]
407+
x u'y'
408+
[out]
409+
file, line 1: Parse error before string literal

0 commit comments

Comments
 (0)