backtrace.patch 876 B

123456789101112131415161718192021
  1. --- a/include/pybind11/detail/internals.h (index)
  2. +++ b/include/pybind11/detail/internals.h (working tree)
  3. @@ -12,6 +12,8 @@
  4. #include <exception>
  5. #include <mutex>
  6. #include <thread>
  7. +#include <util/generic/yexception.h>
  8. +#include <util/string/builder.h>
  9. /// Tracks the `internals` and `type_info` ABI version independent of the main library version.
  10. ///
  11. @@ -384,7 +386,8 @@ inline void translate_exception(std::exception_ptr p) {
  12. return;
  13. } catch (const std::exception &e) {
  14. handle_nested_exception(e, p);
  15. - raise_err(PyExc_RuntimeError, e.what());
  16. + TString message = TStringBuilder() << TBackTrace::FromCurrentException().PrintToString() << Endl << e.what() << Endl;
  17. + raise_err(PyExc_RuntimeError, message.c_str());
  18. return;
  19. } catch (const std::nested_exception &e) {
  20. handle_nested_exception(e, p);