summaryrefslogtreecommitdiff
path: root/branches
diff options
context:
space:
mode:
authorpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2009-08-29 03:43:15 +0000
committerpmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035>2009-08-29 03:43:15 +0000
commit19746e1e52b1c448e7846b5329cbf91d4d5547ad (patch)
treefc388551148a350c5b5428891d641d71b7c306ae /branches
parent6df65546e0d7e3d9f95e1af67d523eb15c6d98d0 (diff)
downloadipaddr-py-19746e1e52b1c448e7846b5329cbf91d4d5547ad.tar.gz
copy creation for Address objects.
git-svn-id: https://ipaddr-py.googlecode.com/svn@98 09200d28-7f98-11dd-ad27-0f66e57d2035
Diffstat (limited to 'branches')
-rw-r--r--branches/2.0.x/ipaddr.py14
-rwxr-xr-xbranches/2.0.x/ipaddr_test.py4
2 files changed, 12 insertions, 6 deletions
diff --git a/branches/2.0.x/ipaddr.py b/branches/2.0.x/ipaddr.py
index 941261d..a52da13 100644
--- a/branches/2.0.x/ipaddr.py
+++ b/branches/2.0.x/ipaddr.py
@@ -993,11 +993,13 @@ class IPv4Address(BaseV4, BaseIP):
self._ip = struct.unpack('!I', address)[0]
return
- # we have a string
- if not self._is_valid_ip(address):
- raise IPv4IpValidationError(address)
+ # Assume input argument to be string or any object representation
+ # which converts into a formatted IP string.
+ addr_str = str(address)
+ if not self._is_valid_ip(addr_str):
+ raise IPv4IpValidationError(addr_str)
- self._ip = self._ip_int_from_string(address)
+ self._ip = self._ip_int_from_string(addr_str)
class IPv4Network(BaseV4, BaseNet):
@@ -1556,12 +1558,12 @@ class IPv6Address(BaseV6, BaseIP):
return
# Assume input argument to be string or any object representation
- # which converts into a formatted IP prefix string.
+ # which converts into a formatted IP string.
addr_str = str(address)
if not addr_str:
raise IPv6IpValidationError('')
- self._ip = self._ip_int_from_string(address)
+ self._ip = self._ip_int_from_string(addr_str)
class IPv6Network(BaseV6, BaseNet):
diff --git a/branches/2.0.x/ipaddr_test.py b/branches/2.0.x/ipaddr_test.py
index 3c3bf10..4839f02 100755
--- a/branches/2.0.x/ipaddr_test.py
+++ b/branches/2.0.x/ipaddr_test.py
@@ -654,9 +654,13 @@ class IpaddrUnitTest(unittest.TestCase):
addr2 = ipaddr.IPNetwork(addr1)
addr3 = ipaddr.IPNetwork('2001:658:22a:cafe:200::1/64')
addr4 = ipaddr.IPNetwork(addr3)
+ addr5 = ipaddr.IPv4Address('1.1.1.1')
+ addr6 = ipaddr.IPv6Address('2001:658:22a:cafe:200::1')
self.assertEqual(addr1, addr2)
self.assertEqual(addr3, addr4)
+ self.assertEqual(addr5, ipaddr.IPv4Address(addr5))
+ self.assertEqual(addr6, ipaddr.IPv6Address(addr6))
def testCompressIPv6Address(self):
test_addresses = {