Always display python type information in cast errors (#4463)

* Always display python type information in cast errors

* Address comments

* Update comment
This commit is contained in:
Dustin Spicuzza
2023-02-10 00:21:17 -05:00
committed by GitHub
parent 531144dddc
commit 8dcced29ae
6 changed files with 49 additions and 19 deletions

View File

@@ -381,3 +381,12 @@ def test_pypy_oserror_normalization():
# https://github.com/pybind/pybind11/issues/4075
what = m.test_pypy_oserror_normalization()
assert "this_filename_must_not_exist" in what
def test_fn_cast_int_exception():
with pytest.raises(RuntimeError) as excinfo:
m.test_fn_cast_int(lambda: None)
assert str(excinfo.value).startswith(
"Unable to cast Python instance of type <class 'NoneType'> to C++ type"
)