MCPcopy Create free account
hub / github.com/DeepRec-AI/DeepRec / PyExceptionFetch

Function PyExceptionFetch

tensorflow/python/lib/core/py_util.cc:99–129  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

97}
98
99string PyExceptionFetch() {
100 CHECK(PyErr_Occurred())
101 << "Must only call PyExceptionFetch after an exception.";
102 PyObject* ptype;
103 PyObject* pvalue;
104 PyObject* ptraceback;
105 PyErr_Fetch(&ptype, &pvalue, &ptraceback);
106 PyErr_NormalizeException(&ptype, &pvalue, &ptraceback);
107 string err = ClassName(ptype);
108 if (pvalue) {
109 PyObject* str = PyObject_Str(pvalue);
110
111 if (str) {
112#if PY_MAJOR_VERSION < 3
113 strings::StrAppend(&err, ": ", PyString_AS_STRING(str), "\n");
114#else
115 strings::StrAppend(&err, ": ", PyUnicode_AsUTF8(str), "\n");
116#endif
117 Py_DECREF(str);
118 } else {
119 strings::StrAppend(&err, "(unknown error message)\n");
120 }
121
122 TryAppendTraceback(ptype, pvalue, ptraceback, &err);
123
124 Py_DECREF(pvalue);
125 }
126 Py_DECREF(ptype);
127 Py_XDECREF(ptraceback);
128 return err;
129}
130
131} // end namespace tensorflow

Callers 3

DoCallPyFuncFunction · 0.85
InferShapeAndTypeFunction · 0.85

Calls 3

ClassNameFunction · 0.85
TryAppendTracebackFunction · 0.85
StrAppendFunction · 0.50

Tested by

no test coverage detected