mirror of
https://github.com/davidhalter/parso.git
synced 2025-12-09 14:14:53 +08:00
Add issue: 'bytes can only contain ASCII literal characters.'
This commit is contained in:
@@ -204,6 +204,13 @@ class ErrorFinder(Normalizer):
|
|||||||
self._add_indentation_error(message, spacing)
|
self._add_indentation_error(message, spacing)
|
||||||
else:
|
else:
|
||||||
self._add_syntax_error('invalid syntax', leaf)
|
self._add_syntax_error('invalid syntax', leaf)
|
||||||
|
elif leaf.type == 'string':
|
||||||
|
if 'b' in leaf.string_prefix.lower() \
|
||||||
|
and any(c for c in leaf.value if ord(c) > 127):
|
||||||
|
# TODO add check for python 3
|
||||||
|
# b'ä'
|
||||||
|
message = "bytes can only contain ASCII literal characters."
|
||||||
|
self._add_syntax_error(message, leaf)
|
||||||
elif leaf.value == 'continue':
|
elif leaf.value == 'continue':
|
||||||
in_loop = False
|
in_loop = False
|
||||||
for block in self._context.blocks:
|
for block in self._context.blocks:
|
||||||
|
|||||||
@@ -120,6 +120,7 @@ def test_python_exception_matches(code):
|
|||||||
('[*[] for a in [1]]', '3.5'),
|
('[*[] for a in [1]]', '3.5'),
|
||||||
('{**{} for a in [1]}', '3.5'),
|
('{**{} for a in [1]}', '3.5'),
|
||||||
('"s" b""', '3.5'),
|
('"s" b""', '3.5'),
|
||||||
|
('b"ä"', '3.5'),
|
||||||
]
|
]
|
||||||
)
|
)
|
||||||
def test_python_exception_matches_version(code, version):
|
def test_python_exception_matches_version(code, version):
|
||||||
|
|||||||
Reference in New Issue
Block a user