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.

Title: Error in ipaddress.address_exclude function
Type: behavior Stage: resolved
Components: Library (Lib) Versions: Python 3.6, Python 3.5
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: ncoghlan, out, pmoody, python-dev, serhiy.storchaka, xiang.zhang
Priority: normal Keywords: patch

Created on 2016-02-29 06:29 by out, last changed 2022-04-11 14:58 by admin. This issue is now closed.

File name Uploaded Description Edit
address_exclude.patch xiang.zhang, 2016-03-01 07:19 ipaddress._BaseNetwork.subnets include broadcast network review
Messages (5)
msg260994 - (view) Author: feng liang (out) Date: 2016-02-29 06:29
when i read in document 3.5.1,run the example in ipaddress.address_exclude function 

>>> n1 = ip_network('')
>>> n2 = ip_network('')
>>> list(n1.address_exclude(n2))  

I got:

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "C:\Python 3.5\lib\", line 794, in address_exclude
    s1, s2 = s1.subnets()
ValueError: not enough values to unpack (expected 2, got 1)
msg261037 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-03-01 03:22
In old, IPv4Network('').subnet() returns [IPv4Network(''), IPv4Network('')], but ipaddress returns only [IPv4Network('')]. 

It seems simply change end to end+1 in can solve the problem and pass the test. But maybe there are some side effects.
msg261041 - (view) Author: Xiang Zhang (xiang.zhang) * (Python committer) Date: 2016-03-01 07:19
I propose a patch simply add one to end so that the broadcast address network will appear in the result, which behaves the same as Corresponding tests are added. All tests are passed but I am afraid some logic may break.
msg261042 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2016-03-01 08:21
LGTM. I have wrote similar patch but with different tests.
msg261043 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2016-03-01 08:26
New changeset 6d6c0a7b71f5 by Serhiy Storchaka in branch '3.5':
Issue #26457: Fixed the subnets() methods in IP network classes for the case

New changeset c092148a1b55 by Serhiy Storchaka in branch 'default':
Issue #26457: Fixed the subnets() methods in IP network classes for the case
Date User Action Args
2022-04-11 14:58:28adminsetgithub: 70644
2016-03-01 08:26:58serhiy.storchakasetstatus: open -> closed
resolution: fixed
stage: commit review -> resolved
2016-03-01 08:26:32python-devsetnosy: + python-dev
messages: + msg261043
2016-03-01 08:21:13serhiy.storchakasetassignee: serhiy.storchaka
stage: needs patch -> commit review
messages: + msg261042
versions: + Python 3.6
2016-03-01 07:19:14xiang.zhangsetfiles: + address_exclude.patch
keywords: + patch
messages: + msg261041
2016-03-01 06:19:58serhiy.storchakasetnosy: + serhiy.storchaka

stage: needs patch
2016-03-01 03:22:09xiang.zhangsetmessages: + msg261037
2016-02-29 07:23:34serhiy.storchakasetnosy: + ncoghlan, pmoody
2016-02-29 06:42:51xiang.zhangsetnosy: + xiang.zhang
2016-02-29 06:29:44outcreate