[3.11] gh-113171: gh-65056: Fix "private" (non-global) IP address ranges (GH-113179) (GH-113186) (GH-118177) by encukou · Pull Request #118227 · python/cpython (original) (raw)
GH-113171: Fix "private" (non-global) IP address ranges (GH-113179)
The _private_networks variables, used by various is_private implementations,
were missing some ranges and at the same time had overly strict ranges
(where there are more specific ranges considered globally reachable by
the IANA registries).
This patch updates the ranges with what was missing or otherwise incorrect.
100.64.0.0/10 is left alone, for now, as it's been made special in [1].
The _address_exclude_many() call returns 8 networks for IPv4, 121 networks for IPv6.
[1] #61602
(cherry picked from commit 2a4cbf1)
GH-65056: Improve the IP address' is_global/is_private documentation (GH-113186)
It wasn't clear what the semantics of is_global/is_private are and,
when one gets to the bottom of it, it's not quite so simple (hence
the exceptions listed).
(cherry picked from commit 40d75c2)
(cherry picked from commit f86b17a)
📚 Documentation preview 📚: https://cpython-previews--118227.org.readthedocs.build/