fix: unicode surrogate character in Python exception message. (#4297)

* Fix & test for issue #4288 (unicode surrogate character in Python exception message).

* DRY `message_unavailable_exc`

* fix: add a constexpr

Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>

* style: pre-commit fixes

Co-authored-by: Henry Schreiner <HenrySchreinerIII@gmail.com>
Co-authored-by: Aaron Gokaslan <skylion.aaron@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
Ralf W. Grosse-Kunstleve
2022-10-31 09:18:05 -07:00
committed by Ralf W. Grosse-Kunstleve
parent 6d3a0fc319
commit c3987b1aad
3 changed files with 34 additions and 7 deletions

View File

@@ -105,11 +105,6 @@ struct PythonAlreadySetInDestructor {
py::str s;
};
std::string error_already_set_what(const py::object &exc_type, const py::object &exc_value) {
PyErr_SetObject(exc_type.ptr(), exc_value.ptr());
return py::error_already_set().what();
}
TEST_SUBMODULE(exceptions, m) {
m.def("throw_std_exception",
[]() { throw std::runtime_error("This exception was intentionally thrown."); });