Copilot commented on code in PR #50203:
URL: https://github.com/apache/arrow/pull/50203#discussion_r3468082600
##########
python/pyarrow/array.pxi:
##########
@@ -266,6 +266,24 @@ def array(object obj, type=None, mask=None, size=None,
from_pandas=None,
if type is not None and type.id == _Type_EXTENSION:
extension_type = type
type = type.storage_type
+ # GH-49644: when building a fixed_shape_tensor from a sequence of
arrays,
+ # the converter only sees the flat storage type, so validate the
+ # tensor-specific constraints here where the type is still known.
+ if (isinstance(extension_type, FixedShapeTensorType)
+ and isinstance(obj, (list, tuple))):
Review Comment:
The tensor-specific validation (permutation rejection and multi-dim shape
check) only runs when `obj` is a `list`/`tuple`. Other non-array-like sequences
supported by `ConvertPySequence` (e.g., `collections.deque`, custom `Sequence`
types) will bypass this check and can silently build a permuted
`fixed_shape_tensor` with incorrect layout, or accept multi-dimensional
elements with the wrong shape.
Consider applying the validation to any non-array-like
`collections.abc.Sequence` (excluding `str`/`bytes`) so behavior is consistent
across sequence inputs.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]