From 869467f1a125e90db5d373626a3b758567ca4283 Mon Sep 17 00:00:00 2001 From: "pmoody@google.com" Date: Sun, 4 Dec 2011 19:28:43 +0000 Subject: fix exploding network bug git-svn-id: https://ipaddr-py.googlecode.com/svn@240 09200d28-7f98-11dd-ad27-0f66e57d2035 --- branches/3144/ipaddr.py | 9 ++++++--- branches/3144/ipaddr_test.py | 3 +++ 2 files changed, 9 insertions(+), 3 deletions(-) diff --git a/branches/3144/ipaddr.py b/branches/3144/ipaddr.py index 79345ce..5487d7a 100644 --- a/branches/3144/ipaddr.py +++ b/branches/3144/ipaddr.py @@ -1657,10 +1657,13 @@ class _BaseV6(object): A string, the expanded IPv6 address. """ - if isinstance(self, _BaseInterface): - ip_str = str(self.ip) - else: + if isinstance(self, IPv6Network): + ip_str = str(self.network_address) + elif isinstance(self, _BaseAddress): ip_str = str(self) + else: + # _BaseInterface + ip_str = str(self.ip) ip_int = self._ip_int_from_string(ip_str) parts = [] diff --git a/branches/3144/ipaddr_test.py b/branches/3144/ipaddr_test.py index 259d010..0239550 100755 --- a/branches/3144/ipaddr_test.py +++ b/branches/3144/ipaddr_test.py @@ -972,6 +972,7 @@ class IpaddrUnitTest(unittest.TestCase): def testExplodeShortHandIpStr(self): addr1 = ipaddr.IPv6Interface('2001::1') addr2 = ipaddr.IPv6Address('2001:0:5ef5:79fd:0:59d:a0e5:ba1') + addr3 = ipaddr.IPv6Network('2001::/96') self.assertEqual('2001:0000:0000:0000:0000:0000:0000:0001/128', addr1.exploded) self.assertEqual('0000:0000:0000:0000:0000:0000:0000:0001/128', @@ -979,6 +980,8 @@ class IpaddrUnitTest(unittest.TestCase): # issue 77 self.assertEqual('2001:0000:5ef5:79fd:0000:059d:a0e5:0ba1', addr2.exploded) + self.assertEqual('2001:0000:0000:0000:0000:0000:0000:0000/96', + addr3.exploded) def testIntRepresentation(self): self.assertEqual(16909060, int(self.ipv4)) -- cgit v1.2.1