File tree Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Expand file tree Collapse file tree 1 file changed +5
-8
lines changed Original file line number Diff line number Diff line change @@ -1795,18 +1795,16 @@ def _split_scope_id(ip_str):
1795
1795
ip_str: A string, the IPv6 address.
1796
1796
1797
1797
Returns:
1798
- [addr, scope_id] list .
1798
+ [addr, scope_id] tuple .
1799
1799
"""
1800
1800
if '%' not in ip_str :
1801
1801
return ip_str , None
1802
1802
1803
- split_addr = ip_str .split ('%' )
1804
- if len (split_addr ) > 2 or split_addr [- 1 ] == '' :
1803
+ addr , sep , scope_id = ip_str .partition ('%' )
1804
+ if not sep :
1805
+ scope_id = None
1806
+ elif not scope_id :
1805
1807
raise AddressValueError ('Invalid IPv6 address: "%r"' % ip_str )
1806
- try :
1807
- addr , scope_id = split_addr
1808
- except ValueError :
1809
- return split_addr , None
1810
1808
return addr , scope_id
1811
1809
1812
1810
@property
@@ -1855,7 +1853,6 @@ def __init__(self, address):
1855
1853
self ._ip = int .from_bytes (address , 'big' )
1856
1854
return
1857
1855
1858
-
1859
1856
# Assume input argument to be string or any object representation
1860
1857
# which converts into a formatted IP string.
1861
1858
addr_str = str (address )
You can’t perform that action at this time.
0 commit comments