Skip to content

Commit

Permalink
Ensure TypeError use raise_from for C++->Python overload res. (#3671)
Browse files Browse the repository at this point in the history
  • Loading branch information
Skylion007 authored Jan 31, 2022
1 parent 978617f commit ce18721
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions include/pybind11/pybind11.h
Original file line number Diff line number Diff line change
Expand Up @@ -988,6 +988,13 @@ class cpp_function : public function {
}

append_note_if_missing_header_is_suspected(msg);
#if PY_VERSION_HEX >= 0x03030000
// Attach additional error info to the exception if supported
if (PyErr_Occurred()) {
raise_from(PyExc_TypeError, msg.c_str());
return nullptr;
}
#endif
PyErr_SetString(PyExc_TypeError, msg.c_str());
return nullptr;
}
Expand Down

0 comments on commit ce18721

Please sign in to comment.