mirror of
https://github.com/davidhalter/parso.git
synced 2026-05-11 09:08:40 +08:00
Fix two more TODOs about bytes in Python 2.
This commit is contained in:
@@ -415,8 +415,7 @@ class ErrorFinder(Normalizer):
|
|||||||
first = node.children[0]
|
first = node.children[0]
|
||||||
# e.g. 's' b''
|
# e.g. 's' b''
|
||||||
message = "cannot mix bytes and nonbytes literals"
|
message = "cannot mix bytes and nonbytes literals"
|
||||||
# TODO this check is only relevant for Python 3+
|
if first.type == 'string' and self._version >= (3, 0):
|
||||||
if first.type == 'string':
|
|
||||||
first_is_bytes = _is_bytes_literal(first)
|
first_is_bytes = _is_bytes_literal(first)
|
||||||
for string in node.children[1:]:
|
for string in node.children[1:]:
|
||||||
if first_is_bytes != _is_bytes_literal(string):
|
if first_is_bytes != _is_bytes_literal(string):
|
||||||
@@ -550,8 +549,8 @@ class ErrorFinder(Normalizer):
|
|||||||
elif leaf.type == 'string':
|
elif leaf.type == 'string':
|
||||||
string_prefix = leaf.string_prefix.lower()
|
string_prefix = leaf.string_prefix.lower()
|
||||||
if 'b' in string_prefix \
|
if 'b' in string_prefix \
|
||||||
|
and self._version >= (3, 0) \
|
||||||
and any(c for c in leaf.value if ord(c) > 127):
|
and any(c for c in leaf.value if ord(c) > 127):
|
||||||
# TODO add check for python 3
|
|
||||||
# b'ä'
|
# b'ä'
|
||||||
message = "bytes can only contain ASCII literal characters."
|
message = "bytes can only contain ASCII literal characters."
|
||||||
self._add_syntax_error(message, leaf)
|
self._add_syntax_error(message, leaf)
|
||||||
|
|||||||
@@ -0,0 +1,2 @@
|
|||||||
|
's' b''
|
||||||
|
u's' b'ä'
|
||||||
Reference in New Issue
Block a user