diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2019-08-28 17:43:47 -0600 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-08-28 17:43:47 -0600 |
commit | 766a88d2a1fcc03c74d19a6c04b87ab825819067 (patch) | |
tree | efb7d38b597e623d7e05c29eda2f3521acd4f6e1 | |
parent | 9cc5f99f3281ade5eef6b097f5853eb8bb471416 (diff) | |
parent | bd59cd437be25443d918ddb558563a1581db8738 (diff) | |
download | numpy-766a88d2a1fcc03c74d19a6c04b87ab825819067.tar.gz |
Merge pull request #14364 from hugovk/fix-flake8-2020
MAINT: Fixes for prospective Python 3.10 and 4.0
-rw-r--r-- | numpy/core/setup.py | 2 | ||||
-rw-r--r-- | numpy/distutils/command/build.py | 2 | ||||
-rw-r--r-- | numpy/distutils/command/build_src.py | 2 | ||||
-rw-r--r-- | numpy/testing/_private/parameterized.py | 19 | ||||
-rw-r--r-- | tools/npy_tempita/compat3.py | 2 | ||||
-rwxr-xr-x | tools/swig/test/testFarray.py | 2 |
6 files changed, 14 insertions, 15 deletions
diff --git a/numpy/core/setup.py b/numpy/core/setup.py index 338502791..5ac7752cc 100644 --- a/numpy/core/setup.py +++ b/numpy/core/setup.py @@ -464,7 +464,7 @@ def configuration(parent_package='',top_path=None): moredefs.append(('HAVE_LDOUBLE_%s' % rep, 1)) # Py3K check - if sys.version_info[0] == 3: + if sys.version_info[0] >= 3: moredefs.append(('NPY_PY3K', 1)) # Generate the config.h file from moredefs diff --git a/numpy/distutils/command/build.py b/numpy/distutils/command/build.py index 3d7101582..b3e18b204 100644 --- a/numpy/distutils/command/build.py +++ b/numpy/distutils/command/build.py @@ -38,7 +38,7 @@ class build(old_build): raise ValueError("--parallel/-j argument must be an integer") build_scripts = self.build_scripts old_build.finalize_options(self) - plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3]) + plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2]) if build_scripts is None: self.build_scripts = os.path.join(self.build_base, 'scripts' + plat_specifier) diff --git a/numpy/distutils/command/build_src.py b/numpy/distutils/command/build_src.py index 41bb01da5..e183b2090 100644 --- a/numpy/distutils/command/build_src.py +++ b/numpy/distutils/command/build_src.py @@ -90,7 +90,7 @@ class build_src(build_ext.build_ext): self.data_files = self.distribution.data_files or [] if self.build_src is None: - plat_specifier = ".%s-%s" % (get_platform(), sys.version[0:3]) + plat_specifier = ".{}-{}.{}".format(get_platform(), *sys.version_info[:2]) self.build_src = os.path.join(self.build_base, 'src'+plat_specifier) # py_modules_dict is used in build_py.find_package_modules diff --git a/numpy/testing/_private/parameterized.py b/numpy/testing/_private/parameterized.py index a5fa4fb5e..489d8e09a 100644 --- a/numpy/testing/_private/parameterized.py +++ b/numpy/testing/_private/parameterized.py @@ -45,11 +45,18 @@ except ImportError: from unittest import TestCase -PY3 = sys.version_info[0] == 3 PY2 = sys.version_info[0] == 2 -if PY3: +if PY2: + from types import InstanceType + lzip = zip + text_type = unicode + bytes_type = str + string_types = basestring, + def make_method(func, instance, type): + return MethodType(func, instance, type) +else: # Python 3 doesn't have an InstanceType, so just use a dummy type. class InstanceType(): pass @@ -61,14 +68,6 @@ if PY3: if instance is None: return func return MethodType(func, instance) -else: - from types import InstanceType - lzip = zip - text_type = unicode - bytes_type = str - string_types = basestring, - def make_method(func, instance, type): - return MethodType(func, instance, type) _param = namedtuple("param", "args kwargs") diff --git a/tools/npy_tempita/compat3.py b/tools/npy_tempita/compat3.py index eb890ca14..01d771345 100644 --- a/tools/npy_tempita/compat3.py +++ b/tools/npy_tempita/compat3.py @@ -5,7 +5,7 @@ import sys __all__ = ['PY3', 'b', 'basestring_', 'bytes', 'next', 'is_unicode', 'iteritems'] -PY3 = True if sys.version_info[0] == 3 else False +PY3 = True if sys.version_info[0] >= 3 else False if sys.version_info[0] < 3: diff --git a/tools/swig/test/testFarray.py b/tools/swig/test/testFarray.py index 0037dc9b3..e8bf711c5 100755 --- a/tools/swig/test/testFarray.py +++ b/tools/swig/test/testFarray.py @@ -15,7 +15,7 @@ else: BadListError = ValueError # Add the distutils-generated build directory to the python search path and then # import the extension module -libDir = "lib.%s-%s" % (get_platform(), sys.version[:3]) +libDir = "lib.{}-{}.{}".format(get_platform(), *sys.version_info[:2]) sys.path.insert(0, os.path.join("build", libDir)) import Farray |