diff options
author | njsmith <njs@pobox.com> | 2013-02-28 12:10:05 -0800 |
---|---|---|
committer | njsmith <njs@pobox.com> | 2013-02-28 12:10:05 -0800 |
commit | 4b361f62be7f750dc385d0b7dc7529ad9af5e4ea (patch) | |
tree | cbe8daa0a9806b2fa84e35d55af391f97a9ced98 /numpy/core | |
parent | e1c7c4df0c7afb0baff683c7e3a1f4b205d6e572 (diff) | |
parent | dd13084557f46343b9fac0c02725a826d0ca397b (diff) | |
download | numpy-4b361f62be7f750dc385d0b7dc7529ad9af5e4ea.tar.gz |
Merge pull request #3047 from charris/2to3-callable
2to3: Fix callable.
Diffstat (limited to 'numpy/core')
-rw-r--r-- | numpy/core/numeric.py | 5 | ||||
-rw-r--r-- | numpy/core/tests/test_records.py | 3 |
2 files changed, 5 insertions, 3 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 4c5651c3a..f2381a7a6 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -29,6 +29,7 @@ import umath from umath import * import numerictypes from numerictypes import * +import collections if sys.version_info[0] < 3: @@ -2445,8 +2446,8 @@ def seterrcall(func): {'over': 'log', 'divide': 'log', 'invalid': 'log', 'under': 'log'} """ - if func is not None and not callable(func): - if not hasattr(func, 'write') or not callable(func.write): + if func is not None and not isinstance(func, collections.Callable): + if not hasattr(func, 'write') or not isinstance(func.write, collections.Callable): raise ValueError("Only callable can be used as callback") pyvals = umath.geterrobj() old = geterrcall() diff --git a/numpy/core/tests/test_records.py b/numpy/core/tests/test_records.py index 87c661938..2a6403479 100644 --- a/numpy/core/tests/test_records.py +++ b/numpy/core/tests/test_records.py @@ -4,6 +4,7 @@ from numpy.testing import * from numpy.compat import asbytes, asunicode import warnings +import collections class TestFromrecords(TestCase): @@ -94,7 +95,7 @@ class TestFromrecords(TestCase): assert_array_equal(ra['shape'], [['A', 'B', 'C']]) ra.field = 5 assert_array_equal(ra['field'], [[5, 5, 5]]) - assert_(callable(ra.field)) + assert_(isinstance(ra.field, collections.Callable)) def test_fromrecords_with_explicit_dtype(self): a = np.rec.fromrecords([(1, 'a'), (2, 'bbb')], |