Skip to content

Commit 766a88d

Browse files
authored
Merge pull request numpy#14364 from hugovk/fix-flake8-2020
MAINT: Fixes for prospective Python 3.10 and 4.0
2 parents 9cc5f99 + bd59cd4 commit 766a88d

6 files changed

Lines changed: 14 additions & 15 deletions

File tree

numpy/core/setup.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -464,7 +464,7 @@ def generate_config_h(ext, build_dir):
464464
moredefs.append(('HAVE_LDOUBLE_%s' % rep, 1))
465465

466466
# Py3K check
467-
if sys.version_info[0] == 3:
467+
if sys.version_info[0] >= 3:
468468
moredefs.append(('NPY_PY3K', 1))
469469

470470
# Generate the config.h file from moredefs

numpy/distutils/command/build.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ def finalize_options(self):
3838
raise ValueError("--parallel/-j argument must be an integer")
3939
build_scripts = self.build_scripts
4040
old_build.finalize_options(self)
41-
plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
41+
plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2])
4242
if build_scripts is None:
4343
self.build_scripts = os.path.join(self.build_base,
4444
'scripts' + plat_specifier)

numpy/distutils/command/build_src.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ def finalize_options(self):
9090
self.data_files = self.distribution.data_files or []
9191

9292
if self.build_src is None:
93-
plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3])
93+
plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2])
9494
self.build_src = os.path.join(self.build_base, 'src'+plat_specifier)
9595

9696
# py_modules_dict is used in build_py.find_package_modules

numpy/testing/_private/parameterized.py

Lines changed: 9 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,11 +45,18 @@
4545

4646
from unittest import TestCase
4747

48-
PY3 = sys.version_info[0] == 3
4948
PY2 = sys.version_info[0] == 2
5049

5150

52-
if PY3:
51+
if PY2:
52+
from types import InstanceType
53+
lzip = zip
54+
text_type = unicode
55+
bytes_type = str
56+
string_types = basestring,
57+
def make_method(func, instance, type):
58+
return MethodType(func, instance, type)
59+
else:
5360
# Python 3 doesn't have an InstanceType, so just use a dummy type.
5461
class InstanceType():
5562
pass
@@ -61,14 +68,6 @@ def make_method(func, instance, type):
6168
if instance is None:
6269
return func
6370
return MethodType(func, instance)
64-
else:
65-
from types import InstanceType
66-
lzip = zip
67-
text_type = unicode
68-
bytes_type = str
69-
string_types = basestring,
70-
def make_method(func, instance, type):
71-
return MethodType(func, instance, type)
7271

7372
_param = namedtuple("param", "args kwargs")
7473

tools/npy_tempita/compat3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__all__ = ['PY3', 'b', 'basestring_', 'bytes', 'next', 'is_unicode',
66
'iteritems']
77

8-
PY3 = True if sys.version_info[0] == 3 else False
8+
PY3 = True if sys.version_info[0] >= 3 else False
99

1010
if sys.version_info[0] < 3:
1111

tools/swig/test/testFarray.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616
# Add the distutils-generated build directory to the python search path and then
1717
# import the extension module
18-
libDir = "lib.%s-%s" % (get_platform(), sys.version[:3])
18+
libDir = "lib.{}-{}.{}".format(get_platform(), *sys.version_info[:2])
1919
sys.path.insert(0, os.path.join("build", libDir))
2020
import Farray
2121

0 commit comments

Comments
 (0)