Fix two more TODOs about bytes in Python 2.

This commit is contained in:
Dave Halter
2017-08-05 23:12:13 +02:00
parent 0cf5a36652
commit 065081f227
2 changed files with 4 additions and 3 deletions
+2 -3
View File
@@ -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'ä'