44 lines
1.5 KiB
Diff
44 lines
1.5 KiB
Diff
From b30ee26e366bf509b7538d79bfec6c6d38d53f28 Mon Sep 17 00:00:00 2001
|
|
From: Ravi Teja P <rvteja92@gmail.com>
|
|
Date: Mon, 29 Jun 2020 23:09:29 +0530
|
|
Subject: [PATCH] bpo-41004: Resolve hash collisions for IPv4Interface and
|
|
IPv6Interface (GH-21033)
|
|
|
|
The __hash__() methods of classes IPv4Interface and IPv6Interface had issue
|
|
of generating constant hash values of 32 and 128 respectively causing hash collisions.
|
|
The fix uses the hash() function to generate hash values for the objects
|
|
instead of XOR operation
|
|
|
|
Reference:https://github.com/python/cpython/commit/b30ee26e366bf509b7538d79bfec6c6d38d53f28
|
|
Conflict:NA
|
|
|
|
---
|
|
src/pip/_vendor/ipaddress.py | 4 ++--
|
|
1 file changed, 2 insertions(+), 2 deletions(-)
|
|
|
|
diff --git a/src/pip/_vendor/ipaddress.py b/src/pip/_vendor/ipaddress.py
|
|
index 3e6f9e499..19dfc4cdb 100644
|
|
--- a/src/pip/_vendor/ipaddress.py
|
|
+++ b/src/pip/_vendor/ipaddress.py
|
|
@@ -1536,7 +1536,7 @@ class IPv4Interface(IPv4Address):
|
|
return False
|
|
|
|
def __hash__(self):
|
|
- return self._ip ^ self._prefixlen ^ int(self.network.network_address)
|
|
+ return hash((self._ip, self._prefixlen, int(self.network.network_address)))
|
|
|
|
__reduce__ = _IPAddressBase.__reduce__
|
|
|
|
@@ -2229,7 +2229,7 @@ class IPv6Interface(IPv6Address):
|
|
return False
|
|
|
|
def __hash__(self):
|
|
- return self._ip ^ self._prefixlen ^ int(self.network.network_address)
|
|
+ return hash((self._ip, self._prefixlen, int(self.network.network_address)))
|
|
|
|
__reduce__ = _IPAddressBase.__reduce__
|
|
|
|
--
|
|
2.21.0
|
|
|