(hostname)
| 544 | # Valid bracketed hosts are defined in |
| 545 | # https://www.rfc-editor.org/rfc/rfc3986#page-49 and https://url.spec.whatwg.org/ |
| 546 | def _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. |
no test coverage detected
searching dependent graphs…