mirror of
https://github.com/pybind/pybind11.git
synced 2024-11-14 09:34:46 +00:00
Changing cast_error("... Python instance was disowned.") to value_error (which changes RuntimeError to ValueError). (#2880)
This commit is contained in:
parent
01e0045547
commit
666fc0d8e8
@ -388,7 +388,7 @@ private:
|
|||||||
" Python instance is uninitialized.");
|
" Python instance is uninitialized.");
|
||||||
}
|
}
|
||||||
if (!holder().has_pointee()) {
|
if (!holder().has_pointee()) {
|
||||||
throw cast_error("Missing value for wrapped C++ type:"
|
throw value_error("Missing value for wrapped C++ type:"
|
||||||
" Python instance was disowned.");
|
" Python instance was disowned.");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -78,7 +78,7 @@ def test_load_with_rtrn_f(pass_f, rtrn_f, expected):
|
|||||||
def test_pass_unique_ptr_disowns(pass_f, rtrn_f, expected):
|
def test_pass_unique_ptr_disowns(pass_f, rtrn_f, expected):
|
||||||
obj = rtrn_f()
|
obj = rtrn_f()
|
||||||
assert pass_f(obj) == expected
|
assert pass_f(obj) == expected
|
||||||
with pytest.raises(RuntimeError) as exc_info:
|
with pytest.raises(ValueError) as exc_info:
|
||||||
pass_f(obj)
|
pass_f(obj)
|
||||||
assert str(exc_info.value) == (
|
assert str(exc_info.value) == (
|
||||||
"Missing value for wrapped C++ type: Python instance was disowned."
|
"Missing value for wrapped C++ type: Python instance was disowned."
|
||||||
|
@ -17,7 +17,7 @@ def test_pointee_and_ptr_owner(give_up_ownership_via):
|
|||||||
obj = m.pointee()
|
obj = m.pointee()
|
||||||
assert obj.get_int() == 213
|
assert obj.get_int() == 213
|
||||||
owner = m.ptr_owner(obj)
|
owner = m.ptr_owner(obj)
|
||||||
with pytest.raises(RuntimeError) as exc_info:
|
with pytest.raises(ValueError) as exc_info:
|
||||||
obj.get_int()
|
obj.get_int()
|
||||||
assert (
|
assert (
|
||||||
str(exc_info.value)
|
str(exc_info.value)
|
||||||
|
Loading…
Reference in New Issue
Block a user