| 146 | |
| 147 | template <typename ArrowDecimal> |
| 148 | Status InternalDecimalFromPyObject(PyObject* obj, const DecimalType& arrow_type, |
| 149 | ArrowDecimal* out) { |
| 150 | ARROW_DCHECK_NE(obj, NULLPTR); |
| 151 | ARROW_DCHECK_NE(out, NULLPTR); |
| 152 | |
| 153 | if (IsPyInteger(obj)) { |
| 154 | // TODO: add a fast path for small-ish ints |
| 155 | std::string string; |
| 156 | RETURN_NOT_OK(PyObject_StdStringStr(obj, &string)); |
| 157 | return DecimalFromStdString(string, arrow_type, out); |
| 158 | } else if (PyDecimal_Check(obj)) { |
| 159 | return InternalDecimalFromPythonDecimal<ArrowDecimal>(obj, arrow_type, out); |
| 160 | } else { |
| 161 | return Status::TypeError("int or Decimal object expected, got ", |
| 162 | Py_TYPE(obj)->tp_name); |
| 163 | } |
| 164 | } |
| 165 | |
| 166 | } // namespace |
| 167 |
no test coverage detected