diff options
author | pmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035> | 2010-02-06 17:21:21 +0000 |
---|---|---|
committer | pmoody@google.com <pmoody@google.com@09200d28-7f98-11dd-ad27-0f66e57d2035> | 2010-02-06 17:21:21 +0000 |
commit | 4c3a8fd9934f75e55d60cf66f98434aecb134a73 (patch) | |
tree | 4035257f94511063cddca5c3b85684316b52928c | |
parent | e0b8a12efc47931df8f9b312584a8bd490d954b2 (diff) | |
download | ipaddr-py-4c3a8fd9934f75e55d60cf66f98434aecb134a73.tar.gz |
+ cleanup of the excetion text; making the invalid version TypeError's
consistent with each other.
git-svn-id: https://ipaddr-py.googlecode.com/svn@139 09200d28-7f98-11dd-ad27-0f66e57d2035
-rw-r--r-- | trunk/ipaddr.py | 31 |
1 files changed, 13 insertions, 18 deletions
diff --git a/trunk/ipaddr.py b/trunk/ipaddr.py index 7f3bc3a..3e14445 100644 --- a/trunk/ipaddr.py +++ b/trunk/ipaddr.py @@ -197,7 +197,8 @@ def summarize_address_range(first, last): if not (isinstance(first, _BaseIP) and isinstance(last, _BaseIP)): raise TypeError('first and last must be IP addresses, not networks') if first.version != last.version: - raise TypeError('IP addresses must be same version') + raise TypeError("%s and %s are not of the same version" % ( + str(self), str(other))) if first > last: raise ValueError('last IP address must be greater than first') @@ -305,24 +306,18 @@ def collapse_address_list(addresses): for ip in addresses: if isinstance(ip, _BaseIP): if ips and ips[-1]._version != ip._version: - raise TypeError('Can only collapse like-versioned objects -' - ' v%d: %s, v%d %s' % (ips[-1]._version, - str(ips[-1]), - ip._version, str(ip))) + raise TypeError("%s and %s are not of the same version" % ( + str(ip), str(ips[-1]))) ips.append(ip) elif ip._prefixlen == ip._max_prefixlen: if ips and ips[-1]._version != ip._version: - raise TypeError('Can only collapse like-versioned objects -' - ' v%d: %s, v%d %s' % (ips[-1]._version, - str(ips[-1]), - ip._version, str(ip))) + raise TypeError("%s and %s are not of the same version" % ( + str(ip), str(ips[-1]))) ips.append(ip.ip) else: if nets and nets[-1]._version != ip._version: - raise TypeError('Can only collapse like-versioned objects -' - ' v%d: %s, v%d %s' % (ips[-1]._version, - str(ips[-1]), - ip._version, str(ip))) + raise TypeError("%s and %s are not of the same version" % ( + str(ip), str(ips[-1]))) nets.append(ip) # sort and dedup @@ -415,7 +410,7 @@ class _BaseIP(_IPAddrBase): def __lt__(self, other): if self._version != other._version: - raise TypeError("%s and %s aren't of the same version" % ( + raise TypeError("%s and %s are not of the same version" % ( str(self), str(other))) if self._ip != other._ip: return self._ip < other._ip @@ -423,7 +418,7 @@ class _BaseIP(_IPAddrBase): def __gt__(self, other): if self._version != other._version: - raise TypeError("%s and %s aren't of the same version" % ( + raise TypeError("%s and %s are not of the same version" % ( str(self), str(other))) if self._ip != other._ip: return self._ip > other._ip @@ -493,7 +488,7 @@ class _BaseNet(_IPAddrBase): def __lt__(self, other): if self._version != other._version: - raise TypeError("%s and %s aren't of the same version" % ( + raise TypeError("%s and %s are not of the same version" % ( str(self), str(other))) if self.network != other.network: return self.network < other.network @@ -503,7 +498,7 @@ class _BaseNet(_IPAddrBase): def __gt__(self, other): if self._version != other._version: - raise TypeError("%s and %s aren't of the same version" % ( + raise TypeError("%s and %s are not of the same version" % ( str(self), str(other))) if self.network != other.network: return self.network > other.network @@ -644,7 +639,7 @@ class _BaseNet(_IPAddrBase): """ if not self._version == other._version: - raise TypeError("%s and %s aren't of the same version" % ( + raise TypeError("%s and %s are not of the same version" % ( str(self), str(other))) if other not in self: |