| 109 | } |
| 110 | |
| 111 | string PyObjectToString(PyObject* o) { |
| 112 | if (o == nullptr) { |
| 113 | return "<null object>"; |
| 114 | } |
| 115 | PyObject* str = PyObject_Str(o); |
| 116 | if (str) { |
| 117 | #if PY_MAJOR_VERSION < 3 |
| 118 | string s(PyString_AS_STRING(str)); |
| 119 | #else |
| 120 | string s(PyUnicode_AsUTF8(str)); |
| 121 | #endif |
| 122 | Py_DECREF(str); |
| 123 | return tensorflow::strings::StrCat("type=", GetClassName(o), " str=", s); |
| 124 | } else { |
| 125 | return "<failed to execute str() on object>"; |
| 126 | } |
| 127 | } |
| 128 | |
| 129 | class CachedTypeCheck { |
| 130 | public: |
no test coverage detected