diff --git a/include/pybind11/pybind11.h b/include/pybind11/pybind11.h index db91639dc0..fa629324a7 100644 --- a/include/pybind11/pybind11.h +++ b/include/pybind11/pybind11.h @@ -1168,7 +1168,7 @@ class cpp_function : public function { if (!result) { std::string msg = "Unable to convert function return value to a " "Python type! The signature was\n\t"; - msg += it->signature; + msg += (it) ? it->signature : std::string("unavailable"); append_note_if_missing_header_is_suspected(msg); // Attach additional error info to the exception if supported if (PyErr_Occurred()) {