[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2021-04-26 Thread Łukasz Langa

Łukasz Langa  added the comment:


New changeset 10ad7eb2ef61a2ba99341c804c8c960e4f284621 by Pete Wicken in branch 
'3.8':
[3.8] bpo-28577: Special case added to IP v4 and v6 hosts for /32 and /128 
networks (GH-18757) (#25536)
https://github.com/python/cpython/commit/10ad7eb2ef61a2ba99341c804c8c960e4f284621


--
nosy: +lukasz.langa

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2021-04-26 Thread Łukasz Langa

Change by Łukasz Langa :


--
resolution:  -> fixed
stage: patch review -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2021-04-22 Thread Pete Wicken


Change by Pete Wicken :


--
pull_requests: +24255
pull_request: https://github.com/python/cpython/pull/25536

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2021-04-22 Thread Pete Wicken


Change by Pete Wicken :


--
pull_requests: +24252
pull_request: https://github.com/python/cpython/pull/25533

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2021-04-22 Thread Pete Wicken


Change by Pete Wicken :


--
pull_requests: +24251
pull_request: https://github.com/python/cpython/pull/25532

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2020-05-11 Thread Pete Wicken


Pete Wicken  added the comment:

The patch for this has been merged - I guess this can be closed now?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2020-03-09 Thread Ethan Furman


Change by Ethan Furman :


--
versions: +Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2020-03-09 Thread Ethan Furman


Ethan Furman  added the comment:


New changeset 8e9c47a947954c997d4b725f4551d50a1d896722 by Pete Wicken in branch 
'master':
bpo-28577: Special case added to IP v4 and v6 hosts for /32 and /128 networks 
(GH-18757)
https://github.com/python/cpython/commit/8e9c47a947954c997d4b725f4551d50a1d896722


--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2020-03-03 Thread Pete Wicken


Pete Wicken  added the comment:

Ok it was bugging me that they were different, so I also added the same logic 
for IPv6Networks.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2020-03-02 Thread Pete Wicken


Pete Wicken  added the comment:

I've had a go at implementing this. I did not implement for IPv6 as this was 
not mentioned here, but it seems like it would make sense for it as well. I can 
add that in too if you like.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2020-03-02 Thread Pete Wicken


Change by Pete Wicken :


--
keywords: +patch
nosy: +Wicken
nosy_count: 5.0 -> 6.0
pull_requests: +18112
stage:  -> patch review
pull_request: https://github.com/python/cpython/pull/18757

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2019-11-04 Thread Ethan Furman


Ethan Furman  added the comment:

I came across this /32 issue today trying to iterate over the hosts in 
127.0.0.1/32.  I think it's fair to say that any /32 network has precisely one 
host, and that host should by returned by IPv4Network().hosts().

--
nosy: +ethan.furman

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2018-03-20 Thread Xiang Zhang

Xiang Zhang  added the comment:

I fixed #27683 since it looks more like an oversight and regression to me 
instead of a deliberate change. I'd like the behaviour to be consistent across 
versions. As for "/32", it needs discussion or some expert makes a choice.

--
resolution: not a bug -> 
stage: resolved -> 
versions: +Python 3.8 -Python 3.7

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread Nick Coghlan

Nick Coghlan added the comment:

I think this is an area where ipaddress just inherited ipaddr's behaviour 
without challenging it.

As Peter isn't currently particularly active, and I stepped back from ipaddress 
maintenance some time ago (since I don't work heavily enough with raw IP 
addresses to have the right design instincts to arbitrate edge cases like 
this), I'd suggest raising both this and #27683 on python-dev, pointing out 
that we used to have the "/31" special case (treating it the same as "/30") and 
inadvertently lost it in some other refactoring, but have never special cased 
"/32".

--
nosy: +pmoody

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread Xiang Zhang

Xiang Zhang added the comment:

Sorry, it's #27683.

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread era

era added the comment:

Quick googling did not turn up anything like a credible authoritative reference 
for this, but in actual practice, I have seen /32 used to designate a single 
individual IP address in CIDR notation quite a lot.

I can see roughly three options:

  1. Status quo.  Silently surprise users who expect this to work.
  2. Silently fix.  Hard-code /32 to return a range of one IP address.
  3. Let users choose.  Similarly to the "strict=True" keyword argument in the 
constructor method, the code could allow for either lenient or strict semantics.

By the by, I don't see how the bug you linked to is relevant here, did you 
mistype the bug number?  #27863 is about _elementtree

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread Xiang Zhang

Xiang Zhang added the comment:

I am not sure. Actually there is a special case for mask 31, you can see 
#27863. Its result includes both the network and broadcast address. Add Nick to 
see his opinion.

FYI, ipaddress (ipaddr in Py2) always return empty for 32. But there is other 
library returning network address for 32, for example netaddr.

--
nosy: +ncoghlan
status: closed -> open
type:  -> behavior
versions: +Python 3.7 -Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread era

era added the comment:

@xiang.zhang thanks for the quick reply.

I find this behavior surprising.  If I process a list of addresses, like

ips = (
 '10.9.8.7/32'
 '10.11.12.8/28'
)

for test in ['10.9.8.7', '10.11.12.10']:
  if test in [str(y) for x in ips for y in ipaddress.ip_network(x).hosts()]:
print('{0} found'.format(test))
  else:
print('{0} not found'.format(test))

I would expect both addresses to print "found", but that's not how the current 
implementation works.

I agree that the /28 should not include the gateway and broadcast addresses, 
but I would not expect the explicitly listed /32 address to completely 
disappear from the output.

Are my expectations incorrect?  For code like this, what should I use instead, 
if not hosts()?

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread Xiang Zhang

Xiang Zhang added the comment:

hosts() won't return the network address itself and the network broadcast 
address. So for 10.9.8.7/32, it should return [].

--
nosy: +xiang.zhang
resolution:  -> not a bug
stage:  -> resolved
status: open -> closed

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread era

era added the comment:

(Meh, silly typo, of course the expected output is ['10.9.8.7'], sorry about 
that!)

--

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue28577] ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32

2016-11-01 Thread era

New submission from era:

I would expect the following code to return ['10.9.8.8'] but it returns an 
empty list.

yosemite-osx$ python3
Python 3.5.1 (default, Dec 26 2015, 18:08:53) 
[GCC 4.2.1 Compatible Apple LLVM 7.0.2 (clang-700.1.81)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import ipaddress
>>> list(ipaddress.ip_network('10.9.8.7/32').hosts())
[]

This seems to happen for every /32 address.  I'm guessing the logic which wants 
to exclude the gateway and broadcast addresses from a block should treat a /32 
as a special case.

I tried to look for a previous bug submission but I could not find one.  As 
such, it seems peculiar if this has not been reported before.  Is this actually 
expected behavior by some rule I am overlooking?

I tested on Linux 3.4 and OSX Yosemite Homebrew / Python 3.5.1.

--
components: Library (Lib)
messages: 279855
nosy: era
priority: normal
severity: normal
status: open
title: ipaddress.ip_network(...).hosts() returns nothing for an IPv4 /32
versions: Python 3.4, Python 3.5

___
Python tracker 

___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com