summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorMatti Picus <matti.picus@gmail.com>2019-11-12 15:19:38 -0700
committerGitHub <noreply@github.com>2019-11-12 15:19:38 -0700
commit4e8ab26a17b96b7b0bdd41ba5e2cfac09685d153 (patch)
tree81e5bac6d17eb762c6bb02d3f933c387cefcf6ee /numpy
parentc592bf2210567ea58bc52f8e15a5f0de582f889b (diff)
parent9ce99dd8b682754ca0efe0cb2fc1dad9f03fb234 (diff)
downloadnumpy-4e8ab26a17b96b7b0bdd41ba5e2cfac09685d153.tar.gz
Merge pull request #14881 from eric-wieser/dont-export-builtins-in-__all__
BUG: Remove builtins from __all__
Diffstat (limited to 'numpy')
-rw-r--r--numpy/__init__.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index fef8245de..349914b2f 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -158,6 +158,7 @@ else:
# Make these accessible from numpy name-space
# but not imported in from numpy import *
+ # TODO[gh-6103]: Deprecate these
if sys.version_info[0] >= 3:
from builtins import bool, int, float, complex, object, str
unicode = str
@@ -168,14 +169,17 @@ else:
# now that numpy modules are imported, can initialize limits
core.getlimits._register_known_types()
- __all__.extend(['bool', 'int', 'float', 'complex', 'object', 'unicode',
- 'str'])
__all__.extend(['__version__', 'show_config'])
__all__.extend(core.__all__)
__all__.extend(_mat.__all__)
__all__.extend(lib.__all__)
__all__.extend(['linalg', 'fft', 'random', 'ctypeslib', 'ma'])
+ # These are added by `from .core import *` and `core.__all__`, but we
+ # overwrite them above with builtins we do _not_ want to export.
+ __all__.remove('long')
+ __all__.remove('unicode')
+
# Remove things that are in the numpy.lib but not in the numpy namespace
# Note that there is a test (numpy/tests/test_public_api.py:test_numpy_namespace)
# that prevents adding more things to the main namespace by accident.
@@ -216,7 +220,7 @@ else:
"{!r}".format(__name__, attr))
def __dir__():
- return __all__ + ['Tester', 'testing']
+ return list(globals().keys()) + ['Tester', 'testing']
else:
# We don't actually use this ourselves anymore, but I'm not 100% sure that