Skip to content
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

class IPv4Network hosts function does not work when prefixlen is /31 #58

Open
sli35 opened this issue Oct 6, 2020 · 1 comment
Open

Comments

@sli35
Copy link

sli35 commented Oct 6, 2020

Normally, the class IPv4Network "hosts" function is modified to "iter" when mask is /31.
This works well when the network is a string, however when the network is an integer, it does not work.

In the init function of the class, there are two conditions upon which the hosts function is not adjusted:

if isinstance(address, (_compat_int_types, bytes)):

if isinstance(address, tuple):

Modification of hosts, only applies when both conditions are failing:

if self._prefixlen == (self._max_prefixlen - 1):
self.hosts = self.iter

The problem has been discovered when using exclude_address, the result is an iterator of IPv4Network objects created using integers. hosts function does not work when one of the remaining IPv4Network is a /31.

@frenzymadness
Copy link

Is this problem already fixed in CPython ipaddress module? If not, it might make sense to open a bug report on https://bugs.python.org/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants