MCPcopy Create free account
hub / github.com/PaddlePaddle/Paddle / GetPythonStack

Function GetPythonStack

paddle/fluid/pybind/eager_utils.cc:385–395  ·  view source on GitHub ↗

* @brief Get the string representation of the current Python stack * * Use Python’s traceback module to obtain the current stack information and * convert it into a string representation for return. * * @return String representation of the current Python stack */

Source from the content-addressed store, hash-verified

383 * @return String representation of the current Python stack
384 */
385std::string GetPythonStack() {
386 pybind11::gil_scoped_acquire gil;
387 PyObject* mod = PyImport_ImportModule("traceback");
388 PyObject* traceback_list = PyObject_CallMethod(mod, "format_stack", "");
389 std::string str = "";
390 for (Py_ssize_t i = 0; i < PyList_Size(traceback_list); i++) {
391 PyObject* line = PyList_GetItem(traceback_list, i);
392 str += py::str(PyUnicode_AsUTF8(line));
393 }
394 return str;
395}
396void SetPythonStack() {
397 if (FLAGS_check_nan_inf && FLAGS_check_nan_inf_level == 0) {
398 VLOG(4) << "this is SetPythonStack";

Callers 2

TracerClass · 0.85
SetPythonStackFunction · 0.85

Calls 1

strFunction · 0.85

Tested by

no test coverage detected