summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/tests/test_utils.py4
-rw-r--r--numpy/lib/utils.py11
2 files changed, 9 insertions, 6 deletions
diff --git a/numpy/lib/tests/test_utils.py b/numpy/lib/tests/test_utils.py
index 72c91836f..6ad4bfe6d 100644
--- a/numpy/lib/tests/test_utils.py
+++ b/numpy/lib/tests/test_utils.py
@@ -115,6 +115,10 @@ def test_deprecate_preserve_whitespace():
assert_('\n Bizarre' in new_func5.__doc__)
+def test_deprecate_module():
+ assert_(old_func.__module__ == __name__)
+
+
def test_safe_eval_nameconstant():
# Test if safe_eval supports Python 3.4 _ast.NameConstant
utils.safe_eval('None')
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index 2fcf270c4..c0c55ea8e 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -122,11 +122,6 @@ def get_include():
return d
-def _set_function_name(func, name):
- func.__name__ = name
- return func
-
-
class _Deprecate:
"""
Decorator class to deprecate old functions.
@@ -172,7 +167,7 @@ class _Deprecate:
warnings.warn(depdoc, DeprecationWarning, stacklevel=2)
return func(*args, **kwds)
- newfunc = _set_function_name(newfunc, old_name)
+ newfunc.__name__ = old_name
doc = func.__doc__
if doc is None:
doc = depdoc
@@ -200,6 +195,10 @@ class _Deprecate:
pass
else:
newfunc.__dict__.update(d)
+ try:
+ newfunc.__module__ = func.__module__
+ except AttributeError:
+ pass
return newfunc