This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: ipaddress.IPv4Interface won't accept 2-tuple (address, mask)
Type: behavior Stage: resolved
Components: Versions: Python 3.7
process
Status: closed Resolution: duplicate
Dependencies: Superseder: Improvements to ipaddress module
View: 27860
Assigned To: Nosy List: Jacktose, John Florian, SilentGhost
Priority: normal Keywords:

Created on 2019-02-13 19:28 by John Florian, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Messages (3)
msg335474 - (view) Author: John Florian (John Florian) Date: 2019-02-13 19:28
The docs say """The meaning of address is as in the constructor of IPv4Network, except that arbitrary host addresses are always accepted."""

However, that doesn't seem to be entirely true:

>>> tup1 = ('192.168.123.234', 24)
>>> tup2 = ('192.168.123.234', '255.255.255.0')
>>> IPv4Network(tup1, strict=False)
IPv4Network('192.168.123.0/24')
>>> IPv4Network(tup2, strict=False)
IPv4Network('192.168.123.0/24')
>>> IPv4Interface(tup1)
IPv4Interface('192.168.123.234/24')
>>> IPv4Interface(tup2)
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/lib64/python3.7/ipaddress.py", line 1391, in __init__
    self._prefixlen = int(address[1])
ValueError: invalid literal for int() with base 10: '255.255.255.0'
msg343331 - (view) Author: Jack (Jacktose) Date: 2019-05-23 22:31
confirmed in 3.7.3
msg343348 - (view) Author: SilentGhost (SilentGhost) * (Python triager) Date: 2019-05-24 08:00
This seems to have been fixed in #27860 (in master) particularly  6fa84bd12c4b83bee6a41b989363230d5c03b96c. I'm not sure why it was decided against backporting to 3.7 as no new features were introduced, but it's perhaps better to raise this question in that issue. I'm going to close this as a duplicate.
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80171
2019-05-24 08:00:30SilentGhostsetstatus: open -> closed

superseder: Improvements to ipaddress module
nosy: + SilentGhost

messages: + msg343348
type: behavior
resolution: duplicate
stage: resolved
2019-05-23 22:31:47Jacktosesetnosy: + Jacktose
messages: + msg343331
2019-02-13 19:28:48John Floriancreate