#include "onnxruntime_pybind_exceptions.h" #include "onnxruntime_pybind_state_common.h" namespace onnxruntime { namespace python { namespace py = pybind11; const std::string onnxruntime::python::SessionObjectInitializer::default_logger_id = "Default"; void ThrowIfPyErrOccured() { if (PyErr_Occurred()) { PyObject *ptype, *pvalue, *ptraceback; PyErr_Fetch(&ptype, &pvalue, &ptraceback); PyObject* pStr = PyObject_Str(ptype); std::string sType = py::reinterpret_borrow(pStr); Py_XDECREF(pStr); pStr = PyObject_Str(pvalue); sType += ": "; sType += py::reinterpret_borrow(pStr); Py_XDECREF(pStr); throw Fail(sType); } } } // namespace python } // namespace onnxruntime