diff --git a/include/pybind11/embed.h b/include/pybind11/embed.h index f6c8d9063fa..a0a4ebe5b46 100644 --- a/include/pybind11/embed.h +++ b/include/pybind11/embed.h @@ -157,12 +157,13 @@ inline void initialize_interpreter(bool init_signal_handlers = true, // A failure here indicates a character-encoding failure or the python // interpreter out of memory. Give up. PyConfig_Clear(&config); - throw std::runtime_error("Failed to prepare CPython"); + throw std::runtime_error(PyStatus_IsError() ? status.err_msg + : "Failed to prepare CPython"); } status = Py_InitializeFromConfig(&config); PyConfig_Clear(&config); if (PyStatus_Exception(status)) { - throw std::runtime_error("Failed to init CPython"); + throw std::runtime_error(PyStatus_IsError() ? status.err_msg : "Failed to init CPython"); } if (add_program_dir_to_path) { PyRun_SimpleString("import sys, os.path; "