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.

Author ncoghlan
Recipients m01, ncoghlan, pmoody, python-dev, r.david.murray, Вячеслав
Date 2014-11-16.23:52:59
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1416181979.77.0.301060149381.issue22876@psf.upfronthosting.co.za>
In-reply-to
Content
The Interface classes are actually designed to cover any association of an IP address with a specific network, not just host interface addresses. We knew it was a slight misnomer when we chose it, but network and broadcast addresses weren't considered special enough to be worth separating out (beyond the distinction present in iterating over the whole network range vs just the host addresses).

It's relatively straightforward to write a helper function that only allows the creation of host interfaces:

    def host_interface(address):
        ifaddr = ip_interface(address)
        if ifaddr.ip == ifaddr.network.network_address:
            raise ValueError("'{}' is a network address".format(ifaddr)
        if ifaddr.ip == ifaddr.network.broadcast_address:
            raise ValueError("'{}' is a broadcast address".format(ifaddr)
        return ifaddr

I'm not sure if it's worthwhile to add such a helper function to the module itself.

One argument in favour of adding it is that it may help to emphasise that the normal ip_interface factory function and the *Interface class constructors are *not* restricted purely to host interfaces, and thus allow network and broadcast addresses to be associated with their corresponding network definition.
History
Date User Action Args
2014-11-16 23:52:59ncoghlansetrecipients: + ncoghlan, pmoody, r.david.murray, python-dev, m01, Вячеслав
2014-11-16 23:52:59ncoghlansetmessageid: <1416181979.77.0.301060149381.issue22876@psf.upfronthosting.co.za>
2014-11-16 23:52:59ncoghlanlinkissue22876 messages
2014-11-16 23:52:59ncoghlancreate