summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
Diffstat (limited to 'numpy')
-rw-r--r--numpy/__init__.py94
-rw-r--r--numpy/core/src/multiarray/alloc.c5
-rw-r--r--numpy/tests/test_public_api.py18
3 files changed, 41 insertions, 76 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index 8546238ec..27bedb6c1 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -270,70 +270,54 @@ else:
oldnumeric = 'removed'
numarray = 'removed'
- 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):
- # Warn for expired attributes, and return a dummy function
- # that always raises an exception.
- try:
- msg = __expired_functions__[attr]
- except KeyError:
- pass
- else:
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
-
- def _expired(*args, **kwds):
- raise RuntimeError(msg)
-
- return _expired
-
- # Emit warnings for deprecated attributes
- try:
- val, msg = __deprecated_attrs__[attr]
- except KeyError:
- pass
- else:
- warnings.warn(msg, DeprecationWarning, stacklevel=2)
- return val
-
- # Importing Tester requires importing all of UnitTest which is not a
- # cheap import Since it is mainly used in test suits, we lazy import it
- # here to save on the order of 10 ms of import time for most users
- #
- # The previous way Tester was imported also had a side effect of adding
- # the full `numpy.testing` namespace
- if attr == 'testing':
- import numpy.testing as testing
- return testing
- elif attr == 'Tester':
- from .testing import Tester
- return Tester
-
- raise AttributeError("module {!r} has no attribute "
- "{!r}".format(__name__, attr))
-
- def __dir__():
- return list(globals().keys() | {'Tester', 'testing'})
+ def __getattr__(attr):
+ # Warn for expired attributes, and return a dummy function
+ # that always raises an exception.
+ try:
+ msg = __expired_functions__[attr]
+ except KeyError:
+ pass
+ else:
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
- else:
- # We don't actually use this ourselves anymore, but I'm not 100% sure that
- # no-one else in the world is using it (though I hope not)
- from .testing import Tester
+ def _expired(*args, **kwds):
+ raise RuntimeError(msg)
- # We weren't able to emit a warning about these, so keep them around
- globals().update({
- k: v
- for k, (v, msg) in __deprecated_attrs__.items()
- })
+ return _expired
+ # Emit warnings for deprecated attributes
+ try:
+ val, msg = __deprecated_attrs__[attr]
+ except KeyError:
+ pass
+ else:
+ warnings.warn(msg, DeprecationWarning, stacklevel=2)
+ return val
+
+ # Importing Tester requires importing all of UnitTest which is not a
+ # cheap import Since it is mainly used in test suits, we lazy import it
+ # here to save on the order of 10 ms of import time for most users
+ #
+ # The previous way Tester was imported also had a side effect of adding
+ # the full `numpy.testing` namespace
+ if attr == 'testing':
+ import numpy.testing as testing
+ return testing
+ elif attr == 'Tester':
+ from .testing import Tester
+ return Tester
+
+ raise AttributeError("module {!r} has no attribute "
+ "{!r}".format(__name__, attr))
+
+ def __dir__():
+ return list(globals().keys() | {'Tester', 'testing'})
# Pytest testing
from numpy._pytesttester import PytestTester
test = PytestTester(__name__)
del PytestTester
-
def _sanity_check():
"""
Quick sanity checks for common bugs caused by environment.
diff --git a/numpy/core/src/multiarray/alloc.c b/numpy/core/src/multiarray/alloc.c
index 887deff53..e74056736 100644
--- a/numpy/core/src/multiarray/alloc.c
+++ b/numpy/core/src/multiarray/alloc.c
@@ -3,11 +3,6 @@
#include "structmember.h"
#include <pymem.h>
-/* public api in 3.7 */
-#if PY_VERSION_HEX < 0x03070000
-#define PyTraceMalloc_Track _PyTraceMalloc_Track
-#define PyTraceMalloc_Untrack _PyTraceMalloc_Untrack
-#endif
#define NPY_NO_DEPRECATED_API NPY_API_VERSION
#define _MULTIARRAYMODULE
diff --git a/numpy/tests/test_public_api.py b/numpy/tests/test_public_api.py
index 3fa2edd8f..ad04f5cec 100644
--- a/numpy/tests/test_public_api.py
+++ b/numpy/tests/test_public_api.py
@@ -52,22 +52,8 @@ def test_numpy_namespace():
'show_config': 'numpy.__config__.show',
'who': 'numpy.lib.utils.who',
}
- if sys.version_info < (3, 7):
- # These built-in types are re-exported by numpy.
- builtins = {
- 'bool': 'builtins.bool',
- 'complex': 'builtins.complex',
- 'float': 'builtins.float',
- 'int': 'builtins.int',
- 'long': 'builtins.int',
- 'object': 'builtins.object',
- 'str': 'builtins.str',
- 'unicode': 'builtins.str',
- }
- allowlist = dict(undocumented, **builtins)
- else:
- # after 3.7, we override dir to not show these members
- allowlist = undocumented
+ # We override dir to not show these members
+ allowlist = undocumented
bad_results = check_dir(np)
# pytest gives better error messages with the builtin assert than with
# assert_equal