diff options
author | Brandt Bucher <brandtbucher@gmail.com> | 2020-03-21 15:11:05 -0700 |
---|---|---|
committer | Brandt Bucher <brandtbucher@gmail.com> | 2020-03-23 17:23:19 -0700 |
commit | 367c5a2138d4bfdeb41c0de9ac8db8b974656f2e (patch) | |
tree | 3be8d4e601ea6d177a14314037b5cc7ecdb1df47 | |
parent | a874132c2d38d39d5d96cd3916038194118bfeb0 (diff) | |
download | numpy-367c5a2138d4bfdeb41c0de9ac8db8b974656f2e.tar.gz |
TST: Add failing regression test for unsafe casts.
Errors raised when casting some strided arrays are not caught.
See gh-15790.
-rw-r--r-- | numpy/core/tests/test_regression.py | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index 97898cc20..06c7ff0b8 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1408,6 +1408,11 @@ class TestRegression: dtype='U') assert_raises(UnicodeEncodeError, np.array, a, 'S4') + def test_unicode_to_string_cast_error(self): + # gh-15790 + a = np.array([u'\x80'] * 129, dtype='U3') + assert_raises(UnicodeEncodeError, np.array, a, 'S') + def test_mixed_string_unicode_array_creation(self): a = np.array(['1234', u'123']) assert_(a.itemsize == 16) @@ -2481,4 +2486,3 @@ class TestRegression: assert arr.size * arr.itemsize > 2 ** 31 c_arr = np.ctypeslib.as_ctypes(arr) assert_equal(c_arr._length_, arr.size) - |