Changing cast_error("... Python instance was disowned.") to value_error (which changes RuntimeError to ValueError). (#2880)

This commit is contained in:
Ralf W. Grosse-Kunstleve 2021-02-26 23:19:23 -08:00 committed by GitHub
parent 01e0045547
commit 666fc0d8e8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 4 additions and 4 deletions

View File

@ -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.");
} }
} }

View File

@ -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."

View File

@ -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)