Skip to content

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

Description

@sli35

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.

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions