Skip to content

ipv6 addresses now need to be valid in 3.9+Β #182

@palfrey

Description

@palfrey

test_hosts has a comment

# Invalid, but well-formed, IPv6 addresses shouldn't raise an
# exception because urlparse.urlsplit() doesn't raise an
# exception on invalid IPv6 addresses.

This I think is true in 3.8 and below, but not in 3.9 (3.9.21 tested) which now gets

ERROR: test_hosts (test_furl.TestFurl)
----------------------------------------------------------------------
Traceback (most recent call last):
  File "/home/palfrey/src/furl/tests/test_furl.py", line 1661, in test_hosts
    furl.furl('http://[0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999]/')
  File "/home/palfrey/src/furl/furl/furl.py", line 1381, in __init__
    self.load(url)  # Raises ValueError on invalid URL.
  File "/home/palfrey/src/furl/furl/furl.py", line 1406, in load
    tokens = urlsplit(url)
  File "/home/palfrey/src/furl/furl/furl.py", line 312, in urlsplit
    scheme, netloc, path, query, fragment = urllib.parse.urlsplit(url)
  File "/home/palfrey/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/urllib/parse.py", line 510, in urlsplit
    _check_bracketed_host(bracketed_host)
  File "/home/palfrey/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/urllib/parse.py", line 453, in _check_bracketed_host
    ip = ipaddress.ip_address(hostname) # Throws Value Error if not IPv6 or IPv4
  File "/home/palfrey/.local/share/uv/python/cpython-3.9.21-linux-x86_64-gnu/lib/python3.9/ipaddress.py", line 53, in ip_address
    raise ValueError(f'{address!r} does not appear to be an IPv4 or IPv6 address')
ValueError: '0:0:0:0:0:0:0:1:1:1:1:1:1:1:1:9999999999999' does not appear to be an IPv4 or IPv6 address

which is breaking the tests. Should these dummy addresses be set to something valid now?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions