Skip to content

Commit

Permalink
apacheGH-39440: [Python] Calling pyarrow.dataset.ParquetFileFormat.ma…
Browse files Browse the repository at this point in the history
…ke_write_options as a class method results in a segfault (apache#40976)

### Rationale for this change

Calling `make_write_options()` method as class instead of instance method results in segfault.

### What changes are included in this PR?

Adds a type check on `self` and raises an error if not `ParquetFileFormat`.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* GitHub Issue: apache#39440

Lead-authored-by: AlenkaF <frim.alenka@gmail.com>
Co-authored-by: Alenka Frim <AlenkaF@users.noreply.github.com>
Co-authored-by: Antoine Pitrou <pitrou@free.fr>
Signed-off-by: AlenkaF <frim.alenka@gmail.com>
  • Loading branch information
2 people authored and rok committed May 8, 2024
1 parent 866af2d commit 8381454
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions python/pyarrow/tests/test_dataset.py
Original file line number Diff line number Diff line change
Expand Up @@ -5633,17 +5633,11 @@ def test_checksum_write_dataset_read_dataset_to_table(tempdir):


def test_make_write_options_error():
# GH-39440: calling make_write_options as a static class method
msg_1 = ("make_write_options() should be called on an "
"instance of ParquetFileFormat")
# GH-41043: In Cython2 all Cython methods were "regular" C extension methods
# see: https://github.com/cython/cython/issues/6127#issuecomment-2038153359
msg_2 = ("descriptor 'make_write_options' for "
"'pyarrow._dataset_parquet.ParquetFileFormat' objects "
"doesn't apply to a 'int'")
with pytest.raises(TypeError) as excinfo:
# GH-39440
msg = ("make_write_options\\(\\) should be called on an "
"instance of ParquetFileFormat")
with pytest.raises(TypeError, match=msg):
pa.dataset.ParquetFileFormat.make_write_options(43)
assert msg_1 in str(excinfo.value) or msg_2 in str(excinfo.value)

pformat = pa.dataset.ParquetFileFormat()
msg = "make_write_options\\(\\) takes exactly 0 positional arguments"
Expand Down

0 comments on commit 8381454

Please sign in to comment.