View the given Python object as string-like, i.e. str or (utf8) bytes
| 368 | |
| 369 | // View the given Python object as string-like, i.e. str or (utf8) bytes |
| 370 | Status ParseString(PyObject* obj, bool check_utf8 = false) { |
| 371 | if (PyUnicode_Check(obj)) { |
| 372 | return ParseUnicode(obj); |
| 373 | } else { |
| 374 | ARROW_RETURN_NOT_OK(ParseBinary(obj)); |
| 375 | if (check_utf8) { |
| 376 | // Check the bytes are utf8 utf-8 |
| 377 | OwnedRef decoded(PyUnicode_FromStringAndSize(bytes, size)); |
| 378 | if (ARROW_PREDICT_TRUE(!PyErr_Occurred())) { |
| 379 | is_utf8 = true; |
| 380 | } else { |
| 381 | PyErr_Clear(); |
| 382 | is_utf8 = false; |
| 383 | } |
| 384 | } |
| 385 | return Status::OK(); |
| 386 | } |
| 387 | } |
| 388 | |
| 389 | // View the given Python object as unicode string |
| 390 | Status ParseUnicode(PyObject* obj) { |
no test coverage detected