Parse bytes from a uuid.UUID object (stores reference to keep bytes alive)
| 421 | |
| 422 | // Parse bytes from a uuid.UUID object (stores reference to keep bytes alive) |
| 423 | Status ParseUuid(PyObject* obj) { |
| 424 | ref.reset(PyObject_GetAttrString(obj, "bytes")); |
| 425 | RETURN_IF_PYERROR(); |
| 426 | if (!PyBytes_Check(ref.obj())) { |
| 427 | return Status::TypeError("Expected uuid.UUID.bytes to return bytes, got '", |
| 428 | Py_TYPE(ref.obj())->tp_name, "' object"); |
| 429 | } |
| 430 | bytes = PyBytes_AS_STRING(ref.obj()); |
| 431 | size = PyBytes_GET_SIZE(ref.obj()); |
| 432 | is_utf8 = false; |
| 433 | return Status::OK(); |
| 434 | } |
| 435 | |
| 436 | protected: |
| 437 | OwnedRef ref; |