Skip to content

Commit

Permalink
GH-38535: [Python] Fix S3FileSystem equals None segfault (#39276)
Browse files Browse the repository at this point in the history
### Rationale for this change

`S3FileSystem` equals `None` currently causes bus error.

### What changes are included in this PR?

Add `not None` to `FileSystem.equals` signature.

### Are these changes tested?

Yes.

### Are there any user-facing changes?

No.
* Closes: #38535

Authored-by: AlenkaF <frim.alenka@gmail.com>
Signed-off-by: Joris Van den Bossche <jorisvandenbossche@gmail.com>
  • Loading branch information
AlenkaF committed Dec 19, 2023
1 parent 659b231 commit f5dd3d4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
2 changes: 1 addition & 1 deletion python/pyarrow/_fs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -505,7 +505,7 @@ cdef class FileSystem(_Weakrefable):
cdef inline shared_ptr[CFileSystem] unwrap(self) nogil:
return self.wrapped

def equals(self, FileSystem other):
def equals(self, FileSystem other not None):
"""
Parameters
----------
Expand Down
7 changes: 7 additions & 0 deletions python/pyarrow/tests/test_fs.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,6 +542,13 @@ def test_filesystem_equals():
assert SubTreeFileSystem('/base', fs0) != SubTreeFileSystem('/other', fs0)


def test_filesystem_equals_none(fs):
with pytest.raises(TypeError, match="got NoneType"):
fs.equals(None)

assert fs is not None


def test_subtree_filesystem():
localfs = LocalFileSystem()

Expand Down

0 comments on commit f5dd3d4

Please sign in to comment.