| 133 | using field_c_type = typename Traits::c_type; |
| 134 | |
| 135 | static Status Field(PyObject* obj, field_c_type* out, bool* found_attrs) { |
| 136 | *out = 0; |
| 137 | for (const MonthDayNanoAttrData* attr = &Traits::attrs[0]; attr->multiplier != 0; |
| 138 | ++attr) { |
| 139 | if (attr->multiplier != 1 && |
| 140 | ::arrow::internal::MultiplyWithOverflow( |
| 141 | static_cast<field_c_type>(attr->multiplier), *out, out)) { |
| 142 | return Status::Invalid("Overflow on: ", (attr - 1)->name, |
| 143 | " for: ", internal::PyObject_StdStringRepr(obj)); |
| 144 | } |
| 145 | |
| 146 | OwnedRef field_value(PyObject_GetAttrString(obj, attr->name)); |
| 147 | if (field_value.obj() == nullptr) { |
| 148 | // No attribute present, skip to the next one. |
| 149 | PyErr_Clear(); |
| 150 | continue; |
| 151 | } |
| 152 | RETURN_IF_PYERROR(); |
| 153 | *found_attrs = true; |
| 154 | field_c_type value; |
| 155 | RETURN_NOT_OK(internal::CIntFromPython(field_value.obj(), &value, attr->name)); |
| 156 | if (::arrow::internal::AddWithOverflow(*out, value, out)) { |
| 157 | return Status::Invalid("Overflow on: ", attr->name, |
| 158 | " for: ", internal::PyObject_StdStringRepr(obj)); |
| 159 | } |
| 160 | } |
| 161 | |
| 162 | return Status::OK(); |
| 163 | } |
| 164 | }; |
| 165 | |
| 166 | // Utility for converting single python objects to their intermediate C representations |
nothing calls this directly
no test coverage detected