Skip to content

Commit

Permalink
fix: include error message if possible in error
Browse files Browse the repository at this point in the history
Signed-off-by: Henry Schreiner <[email protected]>
  • Loading branch information
henryiii committed Jul 5, 2022
1 parent 9b0dad5 commit 380c3d1
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions include/pybind11/embed.h
Original file line number Diff line number Diff line change
Expand Up @@ -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; "
Expand Down

0 comments on commit 380c3d1

Please sign in to comment.