summaryrefslogtreecommitdiff
path: root/netaddr/strategy
diff options
context:
space:
mode:
Diffstat (limited to 'netaddr/strategy')
-rw-r--r--netaddr/strategy/__init__.py10
-rw-r--r--netaddr/strategy/eui48.py6
-rw-r--r--netaddr/strategy/eui64.py2
-rw-r--r--netaddr/strategy/ipv4.py8
-rw-r--r--netaddr/strategy/ipv6.py4
5 files changed, 15 insertions, 15 deletions
diff --git a/netaddr/strategy/__init__.py b/netaddr/strategy/__init__.py
index 31ae431..7b5861d 100644
--- a/netaddr/strategy/__init__.py
+++ b/netaddr/strategy/__init__.py
@@ -95,7 +95,7 @@ def words_to_int(words, word_size, num_words):
by word sequence.
"""
if not valid_words(words, word_size, num_words):
- raise ValueError('invalid integer word sequence: %r!' % words)
+ raise ValueError('invalid integer word sequence: %r!' % (words,))
int_val = 0
for i, num in enumerate(reversed(words)):
@@ -152,7 +152,7 @@ def bits_to_int(bits, width, word_sep=''):
by network address in readable binary form.
"""
if not valid_bits(bits, width, word_sep):
- raise ValueError('invalid readable binary string: %r!' % bits)
+ raise ValueError('invalid readable binary string: %r!' % (bits,))
if word_sep != '':
bits = bits.replace(word_sep, '')
@@ -189,7 +189,7 @@ def int_to_bits(int_val, word_size, num_words, word_sep=''):
if word_sep != '':
# Check custom separator.
if not _is_str(word_sep):
- raise ValueError('word separator is not a string: %r!' % word_sep)
+ raise ValueError('word separator is not a string: %r!' % (word_sep,))
return word_sep.join(bit_words)
@@ -252,7 +252,7 @@ def int_to_bin(int_val, width):
bin_val = '0b' + _re.sub(r'^[0]+([01]+)$', r'\1', ''.join(bin_tokens))
if len(bin_val[2:]) > width:
- raise IndexError('binary string out of bounds: %s!' % bin_val)
+ raise IndexError('binary string out of bounds: %s!' % (bin_val,))
return bin_val
@@ -268,6 +268,6 @@ def bin_to_int(bin_val, width):
by Python binary string format.
"""
if not valid_bin(bin_val, width):
- raise ValueError('not a valid Python binary string: %r!' % bin_val)
+ raise ValueError('not a valid Python binary string: %r!' % (bin_val,))
return int(bin_val.replace('0b', ''), 2)
diff --git a/netaddr/strategy/eui48.py b/netaddr/strategy/eui48.py
index 209c950..5685e34 100644
--- a/netaddr/strategy/eui48.py
+++ b/netaddr/strategy/eui48.py
@@ -173,9 +173,9 @@ def str_to_int(addr):
words = (match_result[0],)
break
if not found_match:
- raise AddrFormatError('%r is not a supported MAC format!' % addr)
+ raise AddrFormatError('%r is not a supported MAC format!' % (addr,))
else:
- raise TypeError('%r is not str() or unicode()!' % addr)
+ raise TypeError('%r is not str() or unicode()!' % (addr,))
int_val = None
@@ -192,7 +192,7 @@ def str_to_int(addr):
# 12 bytes (bare, no delimiters)
int_val = int('%012x' % int(words[0], 16), 16)
else:
- raise AddrFormatError('unexpected word count in MAC address %r!' % addr)
+ raise AddrFormatError('unexpected word count in MAC address %r!' % (addr,))
return int_val
diff --git a/netaddr/strategy/eui64.py b/netaddr/strategy/eui64.py
index 0b9ae35..f4b0ba7 100644
--- a/netaddr/strategy/eui64.py
+++ b/netaddr/strategy/eui64.py
@@ -153,7 +153,7 @@ def str_to_int(addr):
if not words:
raise TypeError
except TypeError:
- raise AddrFormatError('invalid IEEE EUI-64 identifier: %r!' % addr)
+ raise AddrFormatError('invalid IEEE EUI-64 identifier: %r!' % (addr,))
if isinstance(words, tuple):
pass
diff --git a/netaddr/strategy/ipv4.py b/netaddr/strategy/ipv4.py
index fa5e266..56c4f24 100644
--- a/netaddr/strategy/ipv4.py
+++ b/netaddr/strategy/ipv4.py
@@ -126,7 +126,7 @@ def str_to_int(addr, flags=0):
else:
return _struct.unpack('>I', _inet_aton(addr))[0]
except Exception:
- raise AddrFormatError('%r is not a valid IPv4 address string!' % addr)
+ raise AddrFormatError('%r is not a valid IPv4 address string!' % (addr,))
def int_to_str(int_val, dialect=None):
@@ -145,7 +145,7 @@ def int_to_str(int_val, dialect=None):
(int_val >> 8) & 0xff,
int_val & 0xff)
else:
- raise ValueError('%r is not a valid 32-bit unsigned integer!' % int_val)
+ raise ValueError('%r is not a valid 32-bit unsigned integer!' % (int_val,))
def int_to_arpa(int_val):
@@ -195,7 +195,7 @@ def int_to_words(int_val):
"""
if not 0 <= int_val <= max_int:
raise ValueError('%r is not a valid integer value supported by'
- 'this address type!' % int_val)
+ 'this address type!' % (int_val,))
return ( int_val >> 24,
(int_val >> 16) & 0xff,
(int_val >> 8) & 0xff,
@@ -210,7 +210,7 @@ def words_to_int(words):
by word (octet) sequence.
"""
if not valid_words(words):
- raise ValueError('%r is not a valid octet list for an IPv4 address!' % words)
+ raise ValueError('%r is not a valid octet list for an IPv4 address!' % (words,))
return _struct.unpack('>I', _struct.pack('4B', *words))[0]
diff --git a/netaddr/strategy/ipv6.py b/netaddr/strategy/ipv6.py
index eae6678..de2a935 100644
--- a/netaddr/strategy/ipv6.py
+++ b/netaddr/strategy/ipv6.py
@@ -139,7 +139,7 @@ def str_to_int(addr, flags=0):
packed_int = _inet_pton(AF_INET6, addr)
return packed_to_int(packed_int)
except Exception:
- raise AddrFormatError('%r is not a valid IPv6 address string!' % addr)
+ raise AddrFormatError('%r is not a valid IPv6 address string!' % (addr,))
def int_to_str(int_val, dialect=None):
@@ -167,7 +167,7 @@ def int_to_str(int_val, dialect=None):
tokens = [dialect.word_fmt % word for word in words]
addr = word_sep.join(tokens)
except Exception:
- raise ValueError('%r is not a valid 128-bit unsigned integer!' % int_val)
+ raise ValueError('%r is not a valid 128-bit unsigned integer!' % (int_val,))
return addr