MCPcopy Index your code
hub / github.com/python/cpython / _check_bracketed_host

Function _check_bracketed_host

Lib/urllib/parse.py:546–553  ·  view source on GitHub ↗
(hostname)

Source from the content-addressed store, hash-verified

544# Valid bracketed hosts are defined in
545# https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/
546def _check_bracketed_host(hostname):
547 if hostname.startswith('v'):
548 if not re.match(r"\Av[a-fA-F0-9]+\..+\z", hostname):
549 raise ValueError(f"IPvFuture address is invalid")
550 else:
551 ip = ipaddress.ip_address(hostname) # Throws Value Error if not IPv6 or IPv4
552 if isinstance(ip, ipaddress.IPv4Address):
553 raise ValueError(f"An IPv4 address cannot be in brackets")
554
555# typed=True avoids BytesWarnings being emitted during cache key
556# comparison since this API supports both bytes and str input.

Callers 1

_check_bracketed_netlocFunction · 0.85

Calls 2

startswithMethod · 0.45
matchMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…