Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def ip_address(self, value):
try:
import ipaddress
except ImportError:
raise ImportError("You must install the ipaddress backport in Py2")
try:
ipaddress.ip_interface(util.to_unicode(value))
except ValueError:
return False
return True
def _is_valid(self, value):
try:
import ipaddress
except ImportError:
raise ImportError("You must install the ipaddress backport in Py2")
try:
ip = ipaddress.ip_interface(to_unicode(value))
except ValueError:
return False
return self.version == ip.version