Skip to content

Commit

Permalink
Minor comments tweak
Browse files Browse the repository at this point in the history
  • Loading branch information
Guido Imperiale committed Sep 11, 2019
1 parent 7cd8e1c commit 0a84c83
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 3 additions & 3 deletions pint/testsuite/test_issues.py
Original file line number Diff line number Diff line change
Expand Up @@ -703,9 +703,9 @@ def test_issue856b(self):
def test_issue876(self):
# Same hash must not imply equality.

# As an implementation detail of CPython, hash(-1) == hash(-2) This test is
# useless in potential alternative Python implementations where hash(-1) !=
# hash(-2); one would need to find hash collisions specific for each
# As an implementation detail of CPython, hash(-1) == hash(-2).
# This test is useless in potential alternative Python implementations where
# hash(-1) != hash(-2); one would need to find hash collisions specific for each
# implementation

a = UnitsContainer({"[mass]": -1})
Expand Down
7 changes: 4 additions & 3 deletions pint/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -327,11 +327,12 @@ def __setstate__(self, state):

def __eq__(self, other):
if isinstance(other, UnitsContainer):
out = UnitsContainer.__hash__(self) == UnitsContainer.__hash__(other)
# UnitsContainer.__hash__(self) is not the same as hash(self); see
# ParserHelper.__hash__ and __eq__.
# Different hashes guarantee that the actual contents are different, but
# identical hashes give no guarantee of equality
# identical hashes give no guarantee of equality.
# e.g. in CPython, hash(-1) == hash(-2)
if not out:
if UnitsContainer.__hash__(self) != UnitsContainer.__hash__(other):
return False
other = other._d

Expand Down

0 comments on commit 0a84c83

Please sign in to comment.