Skip to content

Commit b4c3b41

Browse files
jorisvandenbosscheraulcd
authored andcommitted
GH-36659: [Python] Fix pyarrow.dataset.Partitioning.__eq__ when comparing with other type (#36661)
### Rationale for this change Ensure that `part == other` doesn't crash with `other` is not a Partitioning instance Small follow-up on #36462 * Closes: #36659 Authored-by: Joris Van den Bossche <[email protected]> Signed-off-by: Joris Van den Bossche <[email protected]>
1 parent 629c6a1 commit b4c3b41

File tree

2 files changed

+3
-3
lines changed

2 files changed

+3
-3
lines changed

python/pyarrow/_dataset.pyx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2348,10 +2348,9 @@ cdef class Partitioning(_Weakrefable):
23482348
return self.wrapped
23492349

23502350
def __eq__(self, other):
2351-
try:
2351+
if isinstance(other, Partitioning):
23522352
return self.partitioning.Equals(deref((<Partitioning>other).unwrap()))
2353-
except TypeError:
2354-
return False
2353+
return False
23552354

23562355
def parse(self, path):
23572356
cdef CResult[CExpression] result

python/pyarrow/tests/test_dataset.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -589,6 +589,7 @@ def test_partitioning():
589589
partitioning = klass(schema)
590590
assert isinstance(partitioning, ds.Partitioning)
591591
assert partitioning == klass(schema)
592+
assert partitioning != "other object"
592593

593594
schema = pa.schema([
594595
pa.field('group', pa.int64()),

0 commit comments

Comments
 (0)