Skip to content

Commit fb2b78d

Browse files
GH-49644: [Python] Keep generic error message for 0-dimensional arrays
Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com>
1 parent 1f8307f commit fb2b78d

1 file changed

Lines changed: 6 additions & 3 deletions

File tree

python/pyarrow/src/arrow/python/python_to_arrow.cc

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -914,9 +914,12 @@ class PyListConverter : public ListConverter<T, PyConverter, PyConverterTrait> {
914914
}
915915
OwnedRef flattened;
916916
if (PyArray_NDIM(ndarray) != 1) {
917-
// GH-49644: 0-dimensional arrays and variable-sized lists only accept
918-
// 1-dimensional values.
919-
if (PyArray_NDIM(ndarray) < 2 || this->list_type_->id() != Type::FIXED_SIZE_LIST) {
917+
// GH-49644: variable-sized lists only accept 1-dimensional values, and
918+
// 0-dimensional arrays are still rejected.
919+
if (PyArray_NDIM(ndarray) < 2) {
920+
return Status::Invalid("Can only convert 1-dimensional array values");
921+
}
922+
if (this->list_type_->id() != Type::FIXED_SIZE_LIST) {
920923
return Status::Invalid(
921924
"Can only convert 1-dimensional array values to a variable-sized list");
922925
}

0 commit comments

Comments
 (0)