Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove residual Python 2 specific code #5828

Merged
merged 7 commits into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions Cython/Compiler/ExprNodes.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,7 @@
Builtin=object, Symtab=object, Utils=object, find_coercion_error=object,
debug_disposal_code=object, debug_temp_alloc=object, debug_coercion=object,
bytearray_type=object, slice_type=object, memoryview_type=object,
builtin_sequence_types=object, _py_int_types=object,
IS_PYTHON3=cython.bint)
builtin_sequence_types=object)

import re
import sys
Expand Down
2 changes: 1 addition & 1 deletion Cython/Compiler/Interpreter.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ def interpret(node, ix):
else:
raise CompileError(node.pos, "Type not allowed here.")
else:
if (isinstance(node, StringNode) and node.unicode_value is not None):
if isinstance(node, StringNode) and node.unicode_value is not None:
return (node.unicode_value, node.pos)
return (node.compile_time_value(empty_scope), node.pos)

Expand Down
5 changes: 1 addition & 4 deletions Cython/Compiler/StringEncoding.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,10 +16,7 @@ def __init__(self):
self.chars = []

def append(self, characters):
if isinstance(characters, bytes):
# this came from a Py2 string literal in the parser code
characters = characters.decode("ASCII")
assert isinstance(characters, str), str(type(characters))
assert isinstance(characters, str), f"Expected str, got {type(characters)}"
self.chars.append(characters)

if sys.maxunicode == 65535:
Expand Down
7 changes: 1 addition & 6 deletions Cython/Compiler/TreePath.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,6 @@
import operator
import sys

if sys.version_info[0] >= 3:
_unicode = str
else:
_unicode = unicode

path_tokenizer = re.compile(
r"("
r"'[^']*'|\"[^\"]*\"|"
Expand Down Expand Up @@ -168,7 +163,7 @@ def select(result):
continue
if attr_value == value:
yield attr_value
elif (isinstance(attr_value, bytes) and isinstance(value, _unicode) and
elif (isinstance(attr_value, bytes) and isinstance(value, str) and
attr_value == value.encode()):
# allow a bytes-to-string comparison too
yield attr_value
Expand Down
Loading