summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorcookedm <cookedm@localhost>2006-06-16 05:18:39 +0000
committercookedm <cookedm@localhost>2006-06-16 05:18:39 +0000
commit8a129527c7fed3c5d88416e92beaa1a7d73186b8 (patch)
treeef9d6179f10e218ca729b175c60533a9429d7e8a /numpy
parentb05d85bd8d6dc1fde66ee40b99be66a338d96424 (diff)
downloadnumpy-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')
-rw-r--r--numpy/core/tests/test_numeric.py5
-rw-r--r--numpy/core/tests/test_numerictypes.py4
-rw-r--r--numpy/lib/utils.py15
3 files changed, 19 insertions, 5 deletions
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py
index 8ee2c4bc3..0a67ab148 100644
--- a/numpy/core/tests/test_numeric.py
+++ b/numpy/core/tests/test_numeric.py
@@ -164,7 +164,8 @@ class test_seterr(ScipyTestCase):
class test_fromiter(ScipyTestCase):
def makegen(self):
- return (x**2 for x in xrange(24))
+ for x in xrange(24):
+ yield x**2
def test_types(self):
ai32 = fromiter(self.makegen(), int32)
@@ -195,4 +196,4 @@ class test_fromiter(ScipyTestCase):
self.failUnless(alltrue(a20 == expected[:20]))
if __name__ == '__main__':
- NumpyTest().run() \ No newline at end of file
+ NumpyTest().run()
diff --git a/numpy/core/tests/test_numerictypes.py b/numpy/core/tests/test_numerictypes.py
index c363d709d..6611d0c1c 100644
--- a/numpy/core/tests/test_numerictypes.py
+++ b/numpy/core/tests/test_numerictypes.py
@@ -322,13 +322,13 @@ class read_values_nested:
class test_read_values_nested_single(read_values_nested, NumpyTestCase):
"""Check the values of heterogeneous arrays (nested, single row)"""
_descr = Ndescr
- multiple_rows = 0
+ multiple_rows = False
_buffer = NbufferT[0]
class test_read_values_nested_multiple(read_values_nested, NumpyTestCase):
"""Check the values of heterogeneous arrays (nested, multiple rows)"""
_descr = Ndescr
- multiple_rows = 1
+ multiple_rows = True
_buffer = NbufferT
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: