1fanwang opened a new pull request, #51163: URL: https://github.com/apache/arrow/pull/51163
### Rationale for this change Several PyArrow APIs accept values that are not the documented Arrow wrapper type, pass a null native pointer into C++, and terminate the Python process. Invalid inputs should raise `TypeError`. Fixes https://github.com/apache/arrow/issues/51042. ### What changes are included in this PR? The affected Parquet, sparse tensor, Substrait, and compute option entry points now validate their wrapper objects before native calls. The same guard covers the matching sibling APIs. ### Are these changes tested? The reported calls were run independently against PyArrow 25.0.1, then covered by focused tests against the patched source. <details> <summary>Raw logs</summary> ```text $ python -c 'import pyarrow.dataset as ds; ds.ParquetReadOptions(binary_type=0)' Segmentation fault: 11 $ python -c 'import pyarrow as pa; pa.SparseCOOTensor.from_tensor(0)' Segmentation fault: 11 $ python -c 'import pyarrow.dataset as ds; ds.ParquetReadOptions(binary_type=0)' TypeError: DataType expected, got <class 'int'> $ python -c 'import pyarrow as pa; pa.SparseCOOTensor.from_tensor(0)' TypeError: Argument 'obj' has incorrect type (expected pyarrow.lib.Tensor, got int) $ pytest -q python/pyarrow/tests -k 'parquet_read_options or parquet_file_rejects_invalid_binary_type or sparse_tensor_from_tensor_rejects_invalid_type or serializing_schema or option_class_equality' ........ [100%] 8 passed, 4 skipped, 8262 deselected ``` </details> ### Are there any user-facing changes? Yes. Invalid wrapper arguments now raise `TypeError` instead of crashing the interpreter. -- 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]
