-
-
Notifications
You must be signed in to change notification settings - Fork 31.7k
Error in ipaddress.address_exclude function #70644
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
when i read in document 3.5.1,run the example in ipaddress.address_exclude function
I got: Traceback (most recent call last):
File "<stdin>", line 1, in <module>
File "C:\Python 3.5\lib\ipaddress.py", line 794, in address_exclude
s1, s2 = s1.subnets()
ValueError: not enough values to unpack (expected 2, got 1) |
In old ipaddr.py, IPv4Network('192.0.2.0/31').subnet() returns [IPv4Network('192.0.2.0/32'), IPv4Network('192.0.2.1/32')], but ipaddress returns only [IPv4Network('192.0.2.0/32')]. It seems simply change end to end+1 in https://hg.python.org/cpython/file/tip/Lib/ipaddress.py#l921 can solve the problem and pass the test. But maybe there are some side effects. |
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 ipaddr.py. Corresponding tests are added. All tests are passed but I am afraid some logic may break. |
LGTM. I have wrote similar patch but with different tests. |
New changeset 6d6c0a7b71f5 by Serhiy Storchaka in branch '3.5': New changeset c092148a1b55 by Serhiy Storchaka in branch 'default': |
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
bugs.python.org fields:
The text was updated successfully, but these errors were encountered: