Skip to content

Commit

Permalink
Merge pull request #1410 from dfalbel/segfault
Browse files Browse the repository at this point in the history
Avoid segfault when raising Python errors that didn't set an exception.
  • Loading branch information
t-kalinowski authored Jul 9, 2023
2 parents 9a712cb + aaa0d72 commit f59e178
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 @@ -661,6 +661,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 f59e178

Please sign in to comment.