aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPhilipp Hagemeister <phihag@phihag.de>2015-11-11 20:58:14 +0100
committerPhilipp Hagemeister <phihag@phihag.de>2015-11-11 20:58:14 +0100
commit1cc2f8d82b4a096295c32cd8c5c853cc05d348fa (patch)
tree7d64dd3f429750a6d1aad3bb005c8d8980b49af2
parente98c02a4987a6cba3c0bc225c2115cf631ea9b33 (diff)
downloadplatform_external_python_ipaddress-1cc2f8d82b4a096295c32cd8c5c853cc05d348fa.tar.gz
platform_external_python_ipaddress-1cc2f8d82b4a096295c32cd8c5c853cc05d348fa.tar.bz2
platform_external_python_ipaddress-1cc2f8d82b4a096295c32cd8c5c853cc05d348fa.zip
Customize warning when bytes are passed in (Closes #24)
-rw-r--r--ipaddress.py6
1 files changed, 6 insertions, 0 deletions
diff --git a/ipaddress.py b/ipaddress.py
index a08eb74..afd7c92 100644
--- a/ipaddress.py
+++ b/ipaddress.py
@@ -192,6 +192,12 @@ def ip_network(address, strict=True):
except (AddressValueError, NetmaskValueError):
pass
+ if isinstance(address, bytes):
+ raise AddressValueError(
+ '%r does not appear to be an IPv4 or IPv6 network. '
+ 'Did you pass in a bytes (str in Python 2) instead of'
+ ' a unicode object?' % address)
+
raise ValueError('%r does not appear to be an IPv4 or IPv6 network' %
address)