diff --git a/Doc/library/ipaddress.rst b/Doc/library/ipaddress.rst index 387d8034bb8c84..7d16357a9f3393 100644 --- a/Doc/library/ipaddress.rst +++ b/Doc/library/ipaddress.rst @@ -519,10 +519,10 @@ dictionaries. The interpretation is similar to an integer *address*. 4. A two-tuple of an address description and a netmask, where the address - description is either a string, a 32-bits integer, a 4-bytes packed - integer, or an existing :class:`IPv4Address` object; and the netmask is either - an integer representing the prefix length (e.g. ``24``) or a string - representing the prefix mask (e.g. ``255.255.255.0``). + description is either a string, a 32-bit integer, a 4-byte packed + integer, or an existing :class:`IPv4Address` object; and the netmask is + either an integer representing the prefix length (e.g. ``24``) or a + string representing the prefix mask (e.g. ``255.255.255.0``). An :exc:`AddressValueError` is raised if *address* is not a valid IPv4 address. A :exc:`NetmaskValueError` is raised if the mask is not valid for @@ -769,9 +769,9 @@ dictionaries. The interpretation is similar to an integer *address*. 4. A two-tuple of an address description and a netmask, where the address - description is either a string, a 128-bits integer, a 16-bytes packed - integer, or an existing :class:`IPv6Address` object; and the netmask is an - integer representing the prefix length. + description is either a string, a 128-bit integer, a 16-byte packed + integer, or an existing :class:`IPv6Address` object; and the netmask is + an integer representing the prefix length. An :exc:`AddressValueError` is raised if *address* is not a valid IPv6 address. A :exc:`NetmaskValueError` is raised if the mask is not valid for diff --git a/Lib/ipaddress.py b/Lib/ipaddress.py index de489c0ed034bb..96a7fde75eb4d0 100644 --- a/Lib/ipaddress.py +++ b/Lib/ipaddress.py @@ -1567,6 +1567,17 @@ def __init__(self, address, strict=True): IPv4Interface(int(IPv4Interface('192.0.2.1'))) == IPv4Interface('192.0.2.1') + The address can also be a two-tuple of an address description + and a netmask, where the address description is either a + string, a 32-bit integer, a 4-byte packed integer, or an + existing IPv4Address object; and the netmask is either an + integer representing the prefix length (e.g. 24) or a string + representing the prefix mask (e.g. '255.255.255.0'). + + strict: A boolean. If true, ensure that we have been passed + a true network address, eg, 192.0.2.0/24 and not an + IP address on a network, eg, 192.0.2.1/24. + Raises: AddressValueError: If ipaddress isn't a valid IPv4 address. NetmaskValueError: If the netmask isn't valid for @@ -2358,8 +2369,14 @@ def __init__(self, address, strict=True): IPv6Network(int(IPv6Network('2001:db8::'))) == IPv6Network('2001:db8::') + The address can also be a two-tuple of an address description and + a netmask, where the address description is either a string, a + 128-bit integer, a 16-byte packed integer, or an existing + IPv6Address object; and the netmask is an integer representing + the prefix length. + strict: A boolean. If true, ensure that we have been passed - A true network address, eg, 2001:db8::1000/124 and not an + a true network address, eg, 2001:db8::1000/124 and not an IP address on a network, eg, 2001:db8::1/124. Raises: