summaryrefslogtreecommitdiff
path: root/numpy/lib/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r--numpy/lib/utils.py21
1 files changed, 5 insertions, 16 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py
index c0c55ea8e..497827e75 100644
--- a/numpy/lib/utils.py
+++ b/numpy/lib/utils.py
@@ -4,6 +4,7 @@ import textwrap
import types
import re
import warnings
+import functools
from numpy.core.numerictypes import issubclass_, issubsctype, issubdtype
from numpy.core.overrides import set_module
@@ -149,10 +150,7 @@ class _Deprecate:
message = self.message
if old_name is None:
- try:
- old_name = func.__name__
- except AttributeError:
- old_name = func.__name__
+ old_name = func.__name__
if new_name is None:
depdoc = "`%s` is deprecated!" % old_name
else:
@@ -162,8 +160,8 @@ class _Deprecate:
if message is not None:
depdoc += "\n" + message
- def newfunc(*args,**kwds):
- """`arrayrange` is deprecated, use `arange` instead!"""
+ @functools.wraps(func)
+ def newfunc(*args, **kwds):
warnings.warn(depdoc, DeprecationWarning, stacklevel=2)
return func(*args, **kwds)
@@ -189,16 +187,7 @@ class _Deprecate:
depdoc = textwrap.indent(depdoc, ' ' * indent)
doc = '\n\n'.join([depdoc, doc])
newfunc.__doc__ = doc
- try:
- d = func.__dict__
- except AttributeError:
- pass
- else:
- newfunc.__dict__.update(d)
- try:
- newfunc.__module__ = func.__module__
- except AttributeError:
- pass
+
return newfunc