mroeschke commented on code in PR #50409:
URL: https://github.com/apache/arrow/pull/50409#discussion_r3641747269
##########
python/pyarrow/src/arrow/python/helpers.cc:
##########
@@ -121,12 +122,27 @@ std::string PyObject_StdStringRepr(PyObject* obj) {
if (!bytes_ref) {
PyErr_Clear();
std::stringstream ss;
- ss << "<object of type '" << Py_TYPE(obj)->tp_name << "' repr() failed>";
+ ss << "<object of type '" << PyObject_StdStringTypeName(obj) << "' repr()
failed>";
return ss.str();
}
return PyBytes_AsStdString(bytes_ref.obj());
}
+std::string PyObject_StdStringTypeName(PyObject* obj) {
+ OwnedRef name_ref(PyType_GetName(Py_TYPE(obj)));
+ if (!name_ref) {
+ PyErr_Clear();
+ return "?";
+ }
+ Py_ssize_t size;
+ const char* data = PyUnicode_AsUTF8AndSize(name_ref.obj(), &size);
Review Comment:
Sure thing,
https://github.com/apache/arrow/pull/50409/changes/b1b1e7284a73c80cfc9d6ca1840e3190f41e862a#diff-1d716e04aaef2cef726c7c6cac5c4ff77b4597a0b362ee55fb9fc42c48e6a09bR149
##########
python/pyarrow/src/arrow/python/helpers.cc:
##########
@@ -89,15 +89,16 @@ Result<uint16_t> PyFloat_AsHalf(PyObject* obj) {
return PyArrayScalar_VAL(obj, Half);
} else {
return Status::TypeError("conversion to float16 expects a `float` or ",
- "`np.float16` object, got ",
Py_TYPE(obj)->tp_name);
+ "`np.float16` object, got ",
+ internal::PyObject_StdStringTypeName(obj));
}
}
namespace internal {
std::string PyBytes_AsStdString(PyObject* obj) {
ARROW_DCHECK(PyBytes_Check(obj));
- return std::string(PyBytes_AS_STRING(obj), PyBytes_GET_SIZE(obj));
+ return std::string(PyBytes_AsString(obj), PyBytes_Size(obj));
Review Comment:
Sure thing
https://github.com/apache/arrow/commit/b1b1e7284a73c80cfc9d6ca1840e3190f41e862a#diff-1d716e04aaef2cef726c7c6cac5c4ff77b4597a0b362ee55fb9fc42c48e6a09bR103
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]