Skip to content

Commit

Permalink
BUG: avoid a deprecation warning in Table.__ne__ (bitwise operator on…
Browse files Browse the repository at this point in the history
… bool values are deprecated in Python 3.12)
  • Loading branch information
neutrinoceros committed Jan 11, 2024
1 parent 3d303f4 commit f1a5b29
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion astropy/table/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -3683,7 +3683,14 @@ def __eq__(self, other):
return self._rows_equal(other)

def __ne__(self, other):
return ~self.__eq__(other)
eq = self.__eq__(other)
if isinstance(eq, bool):

Check warning on line 3687 in astropy/table/table.py

View check run for this annotation

Codecov / codecov/patch

astropy/table/table.py#L3686-L3687

Added lines #L3686 - L3687 were not covered by tests
# bitwise operators on bool values not reliable (e.g. `bool(~True) == True`)
# and are deprecated in Python 3.12
# see https://github.com/python/cpython/pull/103487
return not eq

Check warning on line 3691 in astropy/table/table.py

View check run for this annotation

Codecov / codecov/patch

astropy/table/table.py#L3691

Added line #L3691 was not covered by tests
else:
return ~eq

Check warning on line 3693 in astropy/table/table.py

View check run for this annotation

Codecov / codecov/patch

astropy/table/table.py#L3693

Added line #L3693 was not covered by tests

def _rows_equal(self, other):
"""
Expand Down

0 comments on commit f1a5b29

Please sign in to comment.