diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2011-03-08 09:11:21 -0700 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2011-03-08 09:11:21 -0700 |
commit | 90e4cf055c8b469634cdb6c84e0a8843c2212e78 (patch) | |
tree | 76fa0ff8d501ea36aa1337eb3be2d50b5c18c82e | |
parent | c3f9989fe078fec44671172680e39e100d2a843f (diff) | |
download | numpy-90e4cf055c8b469634cdb6c84e0a8843c2212e78.tar.gz |
TST: Add test for robustness with non-sequence detected as sequence.
-rw-r--r-- | numpy/core/tests/test_multiarray.py | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/numpy/core/tests/test_multiarray.py b/numpy/core/tests/test_multiarray.py index f1165999e..edb64cd61 100644 --- a/numpy/core/tests/test_multiarray.py +++ b/numpy/core/tests/test_multiarray.py @@ -302,6 +302,20 @@ class TestCreation(TestCase): msg = 'String conversion for %s' % type assert_equal(array(nstr, dtype=type), result, err_msg=msg) + def test_non_sequence_sequence(self): + """Should not segfault.""" + class x(object): + def __len__(self): + return 1 + + def __getitem__(self): + raise ValueError('hi there') + + a = np.array([x()]) + assert_(a.shape == (1,)) + assert_(a.dtype == np.dtype(object)) + + class TestStructured(TestCase): def test_subarray_field_access(self): a = np.zeros((3, 5), dtype=[('a', ('i4', (2, 2)))]) |