summaryrefslogtreecommitdiffstats
path: root/Lib/ipaddress.py
diff options
context:
space:
mode:
authorRĂ©mi Lapeyre <remi.lapeyre@henki.fr>2019-04-13 08:49:34 (GMT)
committerInada Naoki <songofacandy@gmail.com>2019-04-13 08:49:34 (GMT)
commite59ec1b05d3e1487ca7754530d3748446c9b7dfd (patch)
tree103d145871d9dfbf16a623d0ab224b3224806352 /Lib/ipaddress.py
parentc88feceb449d6e85d7e17ec36559206094d10d81 (diff)
downloadcpython-e59ec1b05d3e1487ca7754530d3748446c9b7dfd.zip
cpython-e59ec1b05d3e1487ca7754530d3748446c9b7dfd.tar.gz
cpython-e59ec1b05d3e1487ca7754530d3748446c9b7dfd.tar.bz2
bpo-35734: ipaddress: remove unused methods (GH-11591)
Diffstat (limited to 'Lib/ipaddress.py')
-rw-r--r--Lib/ipaddress.py55
1 files changed, 0 insertions, 55 deletions
diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py
index a88cf3d..8c9d740 100644
--- a/Lib/ipaddress.py
+++ b/Lib/ipaddress.py
@@ -1077,9 +1077,6 @@ class _BaseV4:
# Equivalent to 255.255.255.255 or 32 bits of 1's.
_ALL_ONES = (2**IPV4LENGTH) - 1
- # the valid octets for host and netmasks. only useful for IPv4.
- _valid_mask_octets = frozenset({255, 254, 252, 248, 240, 224, 192, 128, 0})
-
_max_prefixlen = IPV4LENGTH
# There are only a handful of valid v4 netmasks, so we cache them all
# when constructed (see _make_netmask()).
@@ -1182,58 +1179,6 @@ class _BaseV4:
"""
return '.'.join(map(str, ip_int.to_bytes(4, 'big')))
- def _is_valid_netmask(self, netmask):
- """Verify that the netmask is valid.
-
- Args:
- netmask: A string, either a prefix or dotted decimal
- netmask.
-
- Returns:
- A boolean, True if the prefix represents a valid IPv4
- netmask.
-
- """
- mask = netmask.split('.')
- if len(mask) == 4:
- try:
- for x in mask:
- if int(x) not in self._valid_mask_octets:
- return False
- except ValueError:
- # Found something that isn't an integer or isn't valid
- return False
- for idx, y in enumerate(mask):
- if idx > 0 and y > mask[idx - 1]:
- return False
- return True
- try:
- netmask = int(netmask)
- except ValueError:
- return False
- return 0 <= netmask <= self._max_prefixlen
-
- def _is_hostmask(self, ip_str):
- """Test if the IP string is a hostmask (rather than a netmask).
-
- Args:
- ip_str: A string, the potential hostmask.
-
- Returns:
- A boolean, True if the IP string is a hostmask.
-
- """
- bits = ip_str.split('.')
- try:
- parts = [x for x in map(int, bits) if x in self._valid_mask_octets]
- except ValueError:
- return False
- if len(parts) != len(bits):
- return False
- if parts[0] < parts[-1]:
- return True
- return False
-
def _reverse_pointer(self):
"""Return the reverse DNS pointer name for the IPv4 address.