| 158 | namespace { |
| 159 | |
| 160 | Status IntegerOverflowStatus(PyObject* obj, const std::string& overflow_message) { |
| 161 | if (overflow_message.empty()) { |
| 162 | std::string obj_as_stdstring; |
| 163 | RETURN_NOT_OK(PyObject_StdStringStr(obj, &obj_as_stdstring)); |
| 164 | return Status::Invalid("Value ", obj_as_stdstring, |
| 165 | " too large to fit in C integer type"); |
| 166 | } else { |
| 167 | return Status::Invalid(overflow_message); |
| 168 | } |
| 169 | } |
| 170 | |
| 171 | Result<OwnedRef> PyObjectToPyInt(PyObject* obj) { |
| 172 | // Try to call __index__ or __int__ on `obj` |
no test coverage detected