| 838 | class PyListConverter : public ListConverter<T, PyConverter, PyConverterTrait> { |
| 839 | public: |
| 840 | Status Append(PyObject* value) override { |
| 841 | if (PyValue::IsNull(this->options_, value)) { |
| 842 | return this->list_builder_->AppendNull(); |
| 843 | } |
| 844 | if (has_numpy() && PyArray_Check(value)) { |
| 845 | RETURN_NOT_OK(AppendNdarray(value)); |
| 846 | } else if (PySequence_Check(value)) { |
| 847 | RETURN_NOT_OK(AppendSequence(value)); |
| 848 | } else if (PySet_Check(value) || (Py_TYPE(value) == &PyDictValues_Type)) { |
| 849 | RETURN_NOT_OK(AppendIterable(value)); |
| 850 | } else if (PyDict_Check(value) && this->type()->id() == Type::MAP) { |
| 851 | // Branch to support Python Dict with `map` DataType. |
| 852 | auto items = PyDict_Items(value); |
| 853 | OwnedRef item_ref(items); |
| 854 | RETURN_NOT_OK(AppendSequence(items)); |
| 855 | } else { |
| 856 | return internal::InvalidType( |
| 857 | value, "was not a sequence or recognized null for conversion to list type"); |
| 858 | } |
| 859 | |
| 860 | return ValidateBuilder(this->list_type_); |
| 861 | } |
| 862 | |
| 863 | protected: |
| 864 | // MapType does not support args in the Append() method |