Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 7 additions & 7 deletions Doc/library/ipaddress.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down
19 changes: 18 additions & 1 deletion Lib/ipaddress.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
Loading