MCPcopy Create free account
hub / github.com/apache/arrow / PyObject_StdStringRepr

Function PyObject_StdStringRepr

python/pyarrow/src/arrow/python/helpers.cc:113–128  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113std::string PyObject_StdStringRepr(PyObject* obj) {
114 OwnedRef unicode_ref(PyObject_Repr(obj));
115 OwnedRef bytes_ref;
116
117 if (unicode_ref) {
118 bytes_ref.reset(
119 PyUnicode_AsEncodedString(unicode_ref.obj(), "utf8", "backslashreplace"));
120 }
121 if (!bytes_ref) {
122 PyErr_Clear();
123 std::stringstream ss;
124 ss << "<object of type '" << Py_TYPE(obj)->tp_name << "' repr() failed>";
125 return ss.str();
126 }
127 return PyBytes_AsStdString(bytes_ref.obj());
128}
129
130Status PyObject_StdStringStr(PyObject* obj, std::string* out) {
131 OwnedRef string_ref(PyObject_Str(obj));

Callers 7

PyObjectToPyIntFunction · 0.85
InvalidValueFunction · 0.85
InvalidTypeFunction · 0.85
DebugPrintFunction · 0.85
SerializeExtInstanceFunction · 0.85
SetInstanceMethod · 0.85
FieldMethod · 0.85

Calls 3

PyBytes_AsStdStringFunction · 0.85
strMethod · 0.80
resetMethod · 0.45

Tested by

no test coverage detected