diff options
-rw-r--r-- | tensorflow/python/eager/pywrap_tfe_src.cc | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/tensorflow/python/eager/pywrap_tfe_src.cc b/tensorflow/python/eager/pywrap_tfe_src.cc index 1a8f3577b2..9f2f4e06ad 100644 --- a/tensorflow/python/eager/pywrap_tfe_src.cc +++ b/tensorflow/python/eager/pywrap_tfe_src.cc @@ -1403,9 +1403,13 @@ class PyVSpace PyObject* arglist = Py_BuildValue("(O)", reinterpret_cast<PyObject*>(tensor)); PyObject* result = PyEval_CallObject(num_elements_, arglist); + Py_DECREF(arglist); + if (result == nullptr) { + // The caller detects whether a python exception has been raised. + return -1; + } tensorflow::int64 r = MakeInt(result); Py_DECREF(result); - Py_DECREF(arglist); return r; } |