diff --git a/python/pyarrow/_compute.pyx b/python/pyarrow/_compute.pyx index 1c98bbfdea2..da237d99fd5 100644 --- a/python/pyarrow/_compute.pyx +++ b/python/pyarrow/_compute.pyx @@ -630,7 +630,7 @@ cdef class FunctionOptions(_Weakrefable): return pyarrow_wrap_buffer(c_buf) @staticmethod - def deserialize(buf): + def deserialize(Buffer buf not None): """ Deserialize options for a function. diff --git a/python/pyarrow/tests/test_compute.py b/python/pyarrow/tests/test_compute.py index d350c811579..483e08b47a4 100644 --- a/python/pyarrow/tests/test_compute.py +++ b/python/pyarrow/tests/test_compute.py @@ -241,6 +241,12 @@ def test_option_class_equality(request): "ArraySortOptions(order=Ascending, null_placement=AtEnd)" +@pytest.mark.parametrize("value", [None, 1, [], b""]) +def test_function_options_deserialize_rejects_non_buffers(value): + with pytest.raises(TypeError): + pc.FunctionOptions.deserialize(value) + + def test_list_functions(): assert len(pc.list_functions()) > 10 assert "add" in pc.list_functions()