mirror of
https://github.com/davidhalter/parso.git
synced 2026-01-15 15:47:02 +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]
|
||||
# e.g. 's' b''
|
||||
message = "cannot mix bytes and nonbytes literals"
|
||||
# TODO this check is only relevant for Python 3+
|
||||
if first.type == 'string':
|
||||
if first.type == 'string' and self._version >= (3, 0):
|
||||
first_is_bytes = _is_bytes_literal(first)
|
||||
for string in node.children[1:]:
|
||||
if first_is_bytes != _is_bytes_literal(string):
|
||||
@@ -550,8 +549,8 @@ class ErrorFinder(Normalizer):
|
||||
elif leaf.type == 'string':
|
||||
string_prefix = leaf.string_prefix.lower()
|
||||
if 'b' in string_prefix \
|
||||
and self._version >= (3, 0) \
|
||||
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)
|
||||
|
||||
2
test/normalizer_issue_files/allowed_syntax_python2.py
Normal file
2
test/normalizer_issue_files/allowed_syntax_python2.py
Normal file
@@ -0,0 +1,2 @@
|
||||
's' b''
|
||||
u's' b'ä'
|
||||
Reference in New Issue
Block a user