diff options
author | Stefan Nordhausen <stefan.nordhausen@immobilienscout24.de> | 2015-07-22 10:55:14 +0200 |
---|---|---|
committer | Stefan Nordhausen <stefan.nordhausen@immobilienscout24.de> | 2015-07-22 10:55:14 +0200 |
commit | 960c06f46efa4bbee806b8f825384868b24c9880 (patch) | |
tree | 17b2b00a7ce20296d9adab68389f094c6439d825 | |
parent | 471624a263efd21ca82f912e3a3ac63ddd5dc27d (diff) | |
download | netaddr-960c06f46efa4bbee806b8f825384868b24c9880.tar.gz |
Issue 96: Do not change behavior for IPv6
-rw-r--r-- | netaddr/ip/__init__.py | 2 | ||||
-rw-r--r-- | test/ip/test_ip_v4.py | 4 |
2 files changed, 5 insertions, 1 deletions
diff --git a/netaddr/ip/__init__.py b/netaddr/ip/__init__.py index f675e23..d8f001e 100644 --- a/netaddr/ip/__init__.py +++ b/netaddr/ip/__init__.py @@ -991,7 +991,7 @@ class IPNetwork(BaseIP, IPListMixin): @property def broadcast(self): """The broadcast address of this `IPNetwork` object""" - if (self._module.width - self._prefixlen) <= 1: + if self._module.version == 4 and (self._module.width - self._prefixlen) <= 1: return None else: return IPAddress(self._value | self._hostmask_int, self._module.version) diff --git a/test/ip/test_ip_v4.py b/test/ip/test_ip_v4.py index e346159..85fcf6a 100644 --- a/test/ip/test_ip_v4.py +++ b/test/ip/test_ip_v4.py @@ -499,3 +499,7 @@ def test_rfc3021_subnets(): assert IPNetwork('192.0.2.0/32').network == IPAddress('192.0.2.0') assert IPNetwork('192.0.2.0/32').broadcast is None assert list(IPNetwork('192.0.2.0/32').iter_hosts()) == [IPAddress('192.0.2.0')] + + # IPv6 must not be affected + assert IPNetwork('abcd::/127').broadcast is not None + assert IPNetwork('abcd::/128').broadcast is not None |