mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-06 06:11:25 +00:00
Change array's writeable exception to a ValueError
Numpy raises ValueError when attempting to modify an array, while py::array is raising a RuntimeError. This changes the exception to a std::domain_error, which gets mapped to the expected ValueError in python.
This commit is contained in:
committed by
Wenzel Jakob
parent
f86dddf7ba
commit
fd7517037b
@@ -92,7 +92,7 @@ def test_mutate_readonly(arr):
|
||||
from pybind11_tests.array import mutate_data, mutate_data_t, mutate_at_t
|
||||
arr.flags.writeable = False
|
||||
for func, args in (mutate_data, ()), (mutate_data_t, ()), (mutate_at_t, (0, 0)):
|
||||
with pytest.raises(RuntimeError) as excinfo:
|
||||
with pytest.raises(ValueError) as excinfo:
|
||||
func(arr, *args)
|
||||
assert str(excinfo.value) == 'array is not writeable'
|
||||
|
||||
|
||||
Reference in New Issue
Block a user