未验证 提交 05ba95e1 编写于 作者: C Chen Weihang 提交者: GitHub

Fix bad alloc exception throw error (#50266)

* fix bad alloc exp error

* remove needless files
上级 7a0fdeb9
......@@ -14,6 +14,7 @@ limitations under the License. */
#include "paddle/fluid/pybind/exception.h"
#include "paddle/fluid/memory/allocation/allocator.h"
#include "paddle/phi/api/ext/exception.h"
namespace paddle {
namespace pybind {
......@@ -41,6 +42,8 @@ void BindException(pybind11::module* m) {
if (p) std::rethrow_exception(p);
} catch (const platform::EOFException& e) {
eof(e.what());
} catch (const memory::allocation::BadAlloc& e) {
PyErr_SetString(PyExc_MemoryError, e.what());
} catch (const platform::EnforceNotMet& e) {
switch (e.code()) {
case paddle::platform::error::INVALID_ARGUMENT:
......@@ -91,6 +94,8 @@ void ThrowExceptionToPython(std::exception_ptr p) {
if (p) std::rethrow_exception(p);
} catch (const platform::EOFException& e) {
PyErr_SetString(EOFExceptionException, e.what());
} catch (const memory::allocation::BadAlloc& e) {
PyErr_SetString(PyExc_MemoryError, e.what());
} catch (const platform::EnforceNotMet& e) {
switch (e.code()) {
case paddle::platform::error::INVALID_ARGUMENT:
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册