File tree Expand file tree Collapse file tree 1 file changed +19
-18
lines changed Expand file tree Collapse file tree 1 file changed +19
-18
lines changed Original file line number Diff line number Diff line change @@ -710,28 +710,29 @@ def is_ip_address(instance):
710
710
return False
711
711
712
712
713
- @FormatChecker .cls_checks ("ipv6" )
714
- def is_ipv6 (instance ):
715
- """
716
- Check whether the instance is a valid IPv6 address.
713
+ if hasattr (socket , "inet_pton" ):
714
+ @FormatChecker .cls_checks ("ipv6" )
715
+ def is_ipv6 (instance ):
716
+ """
717
+ Check whether the instance is a valid IPv6 address.
717
718
718
- :argument str instance: the instance to check
719
- :rtype: bool
719
+ :argument str instance: the instance to check
720
+ :rtype: bool
720
721
721
- >>> is_ipv6("::1")
722
- True
723
- >>> is_ipv6("192.168.0.1")
724
- False
725
- >>> is_ipv6("1:1:1:1:1:1:1:1:1")
726
- False
722
+ >>> is_ipv6("::1")
723
+ True
724
+ >>> is_ipv6("192.168.0.1")
725
+ False
726
+ >>> is_ipv6("1:1:1:1:1:1:1:1:1")
727
+ False
727
728
728
- """
729
+ """
729
730
730
- try :
731
- socket .inet_pton (socket .AF_INET6 , instance )
732
- return True
733
- except socket .error :
734
- return False
731
+ try :
732
+ socket .inet_pton (socket .AF_INET6 , instance )
733
+ return True
734
+ except socket .error :
735
+ return False
735
736
736
737
737
738
@FormatChecker .cls_checks ("host-name" )
You can’t perform that action at this time.
0 commit comments