diff --git a/paddle/fluid/pybind/jit.cc b/paddle/fluid/pybind/jit.cc index 7a3ae85e200f6e6b41d1684b88907ae85f97a3b5..a0e130f40cf646bc4d197a017e38ea7d81523aab 100644 --- a/paddle/fluid/pybind/jit.cc +++ b/paddle/fluid/pybind/jit.cc @@ -206,6 +206,9 @@ static PyObject *_custom_eval_frame(PyThreadState *tstate, // _PyFrame_GetFrameObject(frame) # this function should be the right answer, // but nm libpython.so | grep _PyFrame_MakeAndSetFrameObject is a `t' symbol, // which means it's local to library. we will get a link error if we use it. + if (frame->owner == FRAME_OWNED_BY_GENERATOR) { + return eval_frame_default(tstate, frame, throw_flag); + } if (PyFrame_FastToLocalsWithError(Paddle_PyFrame_GetFrameObject(frame)) < 0) { #else if (PyFrame_FastToLocalsWithError(frame) < 0) {