diff options
author | cookedm <cookedm@localhost> | 2006-06-16 05:18:39 +0000 |
---|---|---|
committer | cookedm <cookedm@localhost> | 2006-06-16 05:18:39 +0000 |
commit | 8a129527c7fed3c5d88416e92beaa1a7d73186b8 (patch) | |
tree | ef9d6179f10e218ca729b175c60533a9429d7e8a /numpy/lib/utils.py | |
parent | b05d85bd8d6dc1fde66ee40b99be66a338d96424 (diff) | |
download | numpy-8a129527c7fed3c5d88416e92beaa1a7d73186b8.tar.gz |
Fix Python 2.3 incompatibilities
- use of a generator in core/tests/test_numeric.py
- you can't set __name__ on a function in 2.3
Diffstat (limited to 'numpy/lib/utils.py')
-rw-r--r-- | numpy/lib/utils.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/lib/utils.py b/numpy/lib/utils.py index 43ccef5cd..ac5b0b9e8 100644 --- a/numpy/lib/utils.py +++ b/numpy/lib/utils.py @@ -1,3 +1,4 @@ +import sys from numpy.core.numerictypes import obj2sctype __all__ = ['issubclass_', 'get_numpy_include', 'issubsctype', 'deprecate'] @@ -27,13 +28,25 @@ def get_numpy_include(): assert len(include_dirs)==1,`include_dirs` return include_dirs[0] +if sys.version_info < (2, 4): + # Can't set __name__ in 2.3 + import new + def _set_function_name(func, name): + func = new.function(func.func_code, func.func_globals, + name, func.func_defaults, func.func_closure) + return func +else: + def _set_function_name(func, name): + func.__name__ = name + return func + def deprecate(func, oldname, newname): import warnings def newfunc(*args,**kwds): warnings.warn("%s is deprecated, use %s" % (oldname, newname), DeprecationWarning) return func(*args, **kwds) - newfunc.__name__ = oldname + newfunc = _set_function_name(newfunc, oldname) doc = func.__doc__ depdoc = '%s is DEPRECATED in numpy: use %s instead' % (oldname, newname,) if doc is None: |