summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorBrigitta Sipőcz <bsipocz@gmail.com>2022-05-20 18:32:55 -0700
committerBrigitta Sipőcz <bsipocz@gmail.com>2022-05-23 09:29:59 -0700
commit53379cd353fb7ab5840c3ee370c735fe61d6419c (patch)
treed3ef9af34179126f996ee3d66d347d0071ddbdd7 /numpy
parenteece996beacc8d78bb48749fe515986ede95bf9e (diff)
downloadnumpy-53379cd353fb7ab5840c3ee370c735fe61d6419c.tar.gz
MAINT: Python <3.7 related cleanups
Diffstat (limited to 'numpy')
-rw-r--r--numpy/core/tests/test_deprecations.py3
-rw-r--r--numpy/core/tests/test_multiarray.py14
-rw-r--r--numpy/core/tests/test_regression.py6
-rw-r--r--numpy/distutils/misc_util.py3
-rw-r--r--numpy/f2py/__init__.py31
-rw-r--r--numpy/lib/tests/test_financial_expired.py2
-rw-r--r--numpy/testing/tests/test_utils.py7
7 files changed, 17 insertions, 49 deletions
diff --git a/numpy/core/tests/test_deprecations.py b/numpy/core/tests/test_deprecations.py
index 5ab72bdaf..09bd5f553 100644
--- a/numpy/core/tests/test_deprecations.py
+++ b/numpy/core/tests/test_deprecations.py
@@ -613,9 +613,6 @@ class TestNonExactMatchDeprecation(_DeprecationTestCase):
class TestDeprecatedGlobals(_DeprecationTestCase):
# 2020-06-06
- @pytest.mark.skipif(
- sys.version_info < (3, 7),
- reason='module-level __getattr__ not supported')
def test_type_aliases(self):
# from builtins
self.assert_deprecated(lambda: np.bool(True))
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py
index cf071a640..ac46b55e6 100644
--- a/numpy/core/tests/test_multiarray.py
+++ b/numpy/core/tests/test_multiarray.py
@@ -4135,13 +4135,6 @@ class TestPickling:
def test_correct_protocol5_error_message(self):
array = np.arange(10)
- if sys.version_info[:2] in ((3, 6), (3, 7)):
- # For the specific case of python3.6 and 3.7, raise a clear import
- # error about the pickle5 backport when trying to use protocol=5
- # without the pickle5 package
- with pytest.raises(ImportError):
- array.__reduce_ex__(5)
-
def test_record_array_with_object_dtype(self):
my_object = object()
@@ -8569,10 +8562,9 @@ class TestConversion:
self_containing = np.array([None])
self_containing[0] = self_containing
- try:
- Error = RecursionError
- except NameError:
- Error = RuntimeError # python < 3.5
+
+ Error = RecursionError
+
assert_raises(Error, bool, self_containing) # previously stack overflow
self_containing[0] = None # resolve circular reference
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py
index e578491b3..937dcb93e 100644
--- a/numpy/core/tests/test_regression.py
+++ b/numpy/core/tests/test_regression.py
@@ -17,12 +17,6 @@ from numpy.testing import (
from numpy.testing._private.utils import _no_tracing, requires_memory
from numpy.compat import asbytes, asunicode, pickle
-try:
- RecursionError
-except NameError:
- RecursionError = RuntimeError # python < 3.5
-
-
class TestRegression:
def test_invalid_round(self):
diff --git a/numpy/distutils/misc_util.py b/numpy/distutils/misc_util.py
index 0bee5a8ec..42bf807d1 100644
--- a/numpy/distutils/misc_util.py
+++ b/numpy/distutils/misc_util.py
@@ -694,8 +694,7 @@ def get_shared_lib_extension(is_python_ext=False):
-----
For Python shared libs, `so_ext` will typically be '.so' on Linux and OS X,
and '.pyd' on Windows. For Python >= 3.2 `so_ext` has a tag prepended on
- POSIX systems according to PEP 3149. For Python 3.2 this is implemented on
- Linux, but not on OS X.
+ POSIX systems according to PEP 3149.
"""
confvars = distutils.sysconfig.get_config_vars()
diff --git a/numpy/f2py/__init__.py b/numpy/f2py/__init__.py
index eb8a050a4..84192f738 100644
--- a/numpy/f2py/__init__.py
+++ b/numpy/f2py/__init__.py
@@ -169,24 +169,19 @@ def get_include():
return os.path.join(os.path.dirname(__file__), 'src')
-if sys.version_info[:2] >= (3, 7):
- # module level getattr is only supported in 3.7 onwards
- # https://www.python.org/dev/peps/pep-0562/
- def __getattr__(attr):
-
- # Avoid importing things that aren't needed for building
- # which might import the main numpy module
- if attr == "test":
- from numpy._pytesttester import PytestTester
- test = PytestTester(__name__)
- return test
+def __getattr__(attr):
- else:
- raise AttributeError("module {!r} has no attribute "
- "{!r}".format(__name__, attr))
+ # Avoid importing things that aren't needed for building
+ # which might import the main numpy module
+ if attr == "test":
+ from numpy._pytesttester import PytestTester
+ test = PytestTester(__name__)
+ return test
+
+ else:
+ raise AttributeError("module {!r} has no attribute "
+ "{!r}".format(__name__, attr))
- def __dir__():
- return list(globals().keys() | {"test"})
-else:
- raise NotImplementedError("F2PY needs Python 3.7")
+def __dir__():
+ return list(globals().keys() | {"test"})
diff --git a/numpy/lib/tests/test_financial_expired.py b/numpy/lib/tests/test_financial_expired.py
index 70b0cd790..838f999a6 100644
--- a/numpy/lib/tests/test_financial_expired.py
+++ b/numpy/lib/tests/test_financial_expired.py
@@ -3,8 +3,6 @@ import pytest
import numpy as np
-@pytest.mark.skipif(sys.version_info[:2] < (3, 7),
- reason="requires python 3.7 or higher")
def test_financial_expired():
match = 'NEP 32'
with pytest.warns(DeprecationWarning, match=match):
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index 4026a7a14..2af0467f1 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -1243,13 +1243,6 @@ def assert_warn_len_equal(mod, n_in_context, py37=None):
# do not count it.
num_warns -= 1
- # Behavior of warnings is Python version dependent. Adjust the
- # expected result to compensate. In particular, Python 3.7 does
- # not make an entry for ignored warnings.
- if sys.version_info[:2] >= (3, 7):
- if py37 is not None:
- n_in_context = py37
-
assert_equal(num_warns, n_in_context)
def test_warn_len_equal_call_scenarios():