diff --git a/paddle/fluid/pybind/exception.cc b/paddle/fluid/pybind/exception.cc index f0b4a6c2d61cd..7061b844987fa 100644 --- a/paddle/fluid/pybind/exception.cc +++ b/paddle/fluid/pybind/exception.cc @@ -42,7 +42,7 @@ void BindException(pybind11::module* m) { try { if (p) std::rethrow_exception(p); } catch (const platform::EOFException& e) { - eof(e.what()); + pybind11::set_error(eof, e.what()); } catch (const memory::allocation::BadAlloc& e) { PyErr_SetString(PyExc_MemoryError, e.what()); } catch (const platform::EnforceNotMet& e) { @@ -77,7 +77,7 @@ void BindException(pybind11::module* m) { PyErr_SetString(PyExc_TypeError, e.what()); break; default: - exc(e.what()); + pybind11::set_error(exc, e.what()); break; } }