diff options
Diffstat (limited to 'modules/language/python/module/ipaddress.py')
-rw-r--r-- | modules/language/python/module/ipaddress.py | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/modules/language/python/module/ipaddress.py b/modules/language/python/module/ipaddress.py index eafbd3e..f084bfa 100644 --- a/modules/language/python/module/ipaddress.py +++ b/modules/language/python/module/ipaddress.py @@ -1532,9 +1532,10 @@ class IPv4Network(_BaseV4, _BaseNetwork): else: arg = self._max_prefixlen self.netmask, self._prefixlen = self._make_netmask(arg) - + xx = int(self.netmask) + yy = int(self.network_address) if strict: - if (IPv4Address(int(self.network_address) & int(self.netmask)) != + if (IPv4Address(yy & xx) != self.network_address): raise ValueError('%s has host bits set' % self) self.network_address = IPv4Address(int(self.network_address) & @@ -2207,6 +2208,7 @@ class IPv6Network(_BaseV6, _BaseNetwork): self.netmask, self._prefixlen = self._make_netmask(arg) self.network_address = IPv6Address(address[0]) packed = int(self.network_address) + if packed & int(self.netmask) != packed: if strict: raise ValueError('%s has host bits set' % self) |