Skip to content

Commit d13fa5f

Browse files
committed
add excpetion clear
1 parent 2da6cac commit d13fa5f

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

paddle/fluid/pybind/sot/guards.cc

+8
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,10 @@ bool TypeMatchGuard::check(PyObject* value) {
8484
bool IdMatchGuard::check(PyObject* value) { return value == expected_; }
8585

8686
bool ValueMatchGuard::check(PyObject* value) {
87+
if (value == NULL) {
88+
PyErr_Clear();
89+
return false;
90+
}
8791
return PyObject_Equal(value, expected_value_);
8892
}
8993

@@ -107,6 +111,10 @@ bool DtypeMatchGuard::check(PyObject* value) {
107111
}
108112

109113
bool ShapeMatchGuard::check(PyObject* value) {
114+
if (value == NULL) {
115+
PyErr_Clear();
116+
return false;
117+
}
110118
auto tensor = GetTensorFromPyObject(value);
111119
if (!tensor) {
112120
return false;

0 commit comments

Comments
 (0)