Commit a6b9117f authored by Dom Sekotill's avatar Dom Sekotill
Browse files

Fix for a breaking "ipaddress" API change

parent bbdd0844
Loading
Loading
Loading
Loading
+10 −2
Original line number Diff line number Diff line
@@ -16,8 +16,16 @@ del _GLOBALS

# Configure for the best backend
if ipaddress:
	net_factory = ipaddress.ip_network
	addr_factory = ipaddress.ip_address
	def net_factory(network):
		"""Return an ipaddress.ip_network which takes a unicode argument"""
		if isinstance(network, bytes):
			network = network.decode()
		return ipaddress.ip_network(network)
	def addr_factory(address):
		"""Return an ipaddress.ip_address which takes a unicode argument"""
		if isinstance(address, bytes):
			address = address.decode()
		return ipaddress.ip_address(address)
elif netaddr:
	net_factory = netaddr.IPNetwork
	addr_factory = netaddr.IPAddress