提交 84a88de8 authored 作者: Brandon T. Willard's avatar Brandon T. Willard

Remove sys.version_info uses for Python 2.x logic

上级 10082356
...@@ -96,9 +96,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env= ...@@ -96,9 +96,7 @@ def run_command(commands, args, cwd=None, verbose=False, hide_stderr=False, env=
if verbose: if verbose:
print("unable to find command, tried %s" % (commands,)) print("unable to find command, tried %s" % (commands,))
return None, None return None, None
stdout = p.communicate()[0].strip() stdout = p.communicate()[0].strip().decode()
if sys.version_info[0] >= 3:
stdout = stdout.decode()
if p.returncode != 0: if p.returncode != 0:
if verbose: if verbose:
print("unable to run %s (error)" % dispcmd) print("unable to run %s (error)" % dispcmd)
......
...@@ -1767,9 +1767,6 @@ def std_lib_dirs_and_libs(): ...@@ -1767,9 +1767,6 @@ def std_lib_dirs_and_libs():
else: else:
if platform.python_implementation() == "PyPy": if platform.python_implementation() == "PyPy":
# Assume Linux (note: Ubuntu doesn't ship this .so) # Assume Linux (note: Ubuntu doesn't ship this .so)
if sys.version_info < (3,):
libname = "pypy-c"
else:
libname = "pypy3-c" libname = "pypy3-c"
# Unfortunately the only convention of this .so is that it appears # Unfortunately the only convention of this .so is that it appears
# next to the location of the interpreter binary. # next to the location of the interpreter binary.
...@@ -2353,7 +2350,7 @@ class GCC_compiler(Compiler): ...@@ -2353,7 +2350,7 @@ class GCC_compiler(Compiler):
# redefinition for recent CPython versions (>=2.7.16 and >=3.7.3). # redefinition for recent CPython versions (>=2.7.16 and >=3.7.3).
# The following nullifies that redefinition, if it is found. # The following nullifies that redefinition, if it is found.
python_version = sys.version_info[:3] python_version = sys.version_info[:3]
if python_version < (2, 7, 16) or (3,) <= python_version < (3, 7, 3): if (3,) <= python_version < (3, 7, 3):
config_h_filename = distutils.sysconfig.get_config_h_filename() config_h_filename = distutils.sysconfig.get_config_h_filename()
try: try:
with open(config_h_filename) as config_h: with open(config_h_filename) as config_h:
......
...@@ -4025,9 +4025,6 @@ class Split(Op): ...@@ -4025,9 +4025,6 @@ class Split(Op):
def perform(self, node, inputs, outputs): def perform(self, node, inputs, outputs):
"""WRITEME""" """WRITEME"""
x, axis, splits = inputs x, axis, splits = inputs
# in python 2.4, x.shape[numpy.asarray(1)] don't work.
if sys.version_info[0:2] == (2, 4) and axis.size == 1:
axis = int(axis)
try: try:
len_along_axis = x.shape[axis] len_along_axis = x.shape[axis]
......
...@@ -1541,21 +1541,7 @@ class IncSubtensor(Op): ...@@ -1541,21 +1541,7 @@ class IncSubtensor(Op):
def convert(entry): def convert(entry):
if isinstance(entry, gof.Type): if isinstance(entry, gof.Type):
rval = indices.pop() return indices.pop()
if sys.version_info < (2, 5):
# Before Python 2.5, PySlice_GetIndicesEx requires
# Python int to be passed.
rval_ = int(rval)
if rval_ != rval:
raise IndexError(
(
"Invalid value for indexing: %s. "
"That value may be too big."
)
% rval
)
return rval_
return rval
elif isinstance(entry, slice): elif isinstance(entry, slice):
return slice( return slice(
convert(entry.start), convert(entry.stop), convert(entry.step) convert(entry.start), convert(entry.stop), convert(entry.step)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论