File tree Expand file tree Collapse file tree 2 files changed +7
-2
lines changed
Expand file tree Collapse file tree 2 files changed +7
-2
lines changed Original file line number Diff line number Diff line change @@ -1661,7 +1661,11 @@ def _ip_int_from_string(cls, ip_str):
16611661 if not ip_str :
16621662 raise AddressValueError ('Address cannot be empty' )
16631663
1664- parts = ip_str .split (':' )
1664+ # We want to allow more parts than the max to be 'split'
1665+ # to preserve the correct error message when there are
1666+ # too many parts combined with '::'
1667+ _max_parts = cls ._HEXTET_COUNT + 1
1668+ parts = ip_str .split (':' , maxsplit = _max_parts )
16651669
16661670 # An IPv6 address needs at least 2 colons (3 parts).
16671671 _min_parts = 3
@@ -1681,7 +1685,6 @@ def _ip_int_from_string(cls, ip_str):
16811685 # An IPv6 address can't have more than 8 colons (9 parts).
16821686 # The extra colon comes from using the "::" notation for a single
16831687 # leading or trailing zero part.
1684- _max_parts = cls ._HEXTET_COUNT + 1
16851688 if len (parts ) > _max_parts :
16861689 msg = "At most %d colons permitted in %r" % (_max_parts - 1 , ip_str )
16871690 raise AddressValueError (msg )
Original file line number Diff line number Diff line change @@ -416,6 +416,8 @@ def assertBadSplit(addr):
416416 # A trailing IPv4 address is two parts
417417 assertBadSplit ("9:8:7:6:5:4:3:42.42.42.42%scope" )
418418 assertBadSplit ("7:6:5:4:3:42.42.42.42%scope" )
419+ # Long IPv6 address
420+ assertBadSplit (("0:" * 10000 ) + "0" )
419421
420422 def test_bad_address_split_v6_too_many_parts_with_double_colon (self ):
421423 def assertBadSplit (addr ):
You can’t perform that action at this time.
0 commit comments