Skip to content

Commit

Permalink
Avoid segfault when raising Python errors that didn't set an exception.
Browse files Browse the repository at this point in the history
  • Loading branch information
dfalbel committed Jul 9, 2023
1 parent efe1f65 commit aaa0d72
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/python.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -693,6 +693,11 @@ SEXP py_fetch_error(bool maybe_reuse_cached_r_trace) {

PyObject *excType, *excValue, *excTraceback;
PyErr_Fetch(&excType, &excValue, &excTraceback); // we now own the PyObjects

if (!excType) {
Rcpp::stop("Unknown Python error.");
}

PyErr_NormalizeException(&excType, &excValue, &excTraceback);

if (excTraceback != NULL && excValue != NULL && s_isPython3) {
Expand Down

0 comments on commit aaa0d72

Please sign in to comment.