Skip to content

Commit eeabe2a

Browse files
committed
gh-134062: Fix hash collisions in IPv4Network and IPv6Network
1 parent 74c4e35 commit eeabe2a

File tree

2 files changed

+2
-1
lines changed

2 files changed

+2
-1
lines changed

Lib/ipaddress.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -729,7 +729,7 @@ def __eq__(self, other):
729729
return NotImplemented
730730

731731
def __hash__(self):
732-
return hash(int(self.network_address) ^ int(self.netmask))
732+
return hash((int(self.network_address), int(self.netmask)))
733733

734734
def __contains__(self, other):
735735
# always false if one is v4 and the other is v6.
Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Fix hash collisions in :class:`IPv4Network` and :class:`IPv6Network`.

0 commit comments

Comments
 (0)