[Python-Dev] Request for comments: [issue22941] IPv4Interface arithmetic changes subnet mask

Eric V. Smith eric at trueblade.com
Thu Mar 12 19:55:05 CET 2015


On 3/12/2015 2:17 PM, Antoine Pitrou wrote:
> On Thu, 12 Mar 2015 14:08:01 -0400
> Scott Dial <scott+python-dev at scottdial.com> wrote:
> 
>> On 2015-03-12 10:46 AM, Eric V. Smith wrote:
>>> On 3/12/2015 10:00 AM, Antoine Pitrou wrote:
>>>> Related issue:
>>>>
>>>>>>> ipaddress.IPv4Interface('10.0.0.255/8') + 1
>>>> IPv4Interface('10.0.1.0/32')
>>>>
>>>> Should the result be IPv4Interface('10.0.0.0/8')
>>>> (i.e. wrap around)? Should OverflowError be raised?
>>>
>>> I think it should be an OverflowError. 10.0.1.0/8 makes no sense, and
>>> 10.0.0.0/8 is unlikely to be desirable.
>>>
>>
>> No, you are both imbuing meaning to the dot-notation that is not there.
>> A.B.C.D is just an ugly way to represent a single 32-bit unsigned
>> integer. The only contentious part would be when your addition would
>> overlfow the host-portion of the address:
>>
>>>>> ipaddress.IPv4Interface('10.255.255.255/8') + 1
>> IPv4Interface('11.0.0.0/8')
> 
> Oh, well, you're right, I borked my subnet. So, for the record, I meant
> "10.0.0.255/24" where the issue actually appears.

I, too, was thinking /24. I think that overflowing the host portion
should raise OverflowError.

-- 
Eric.


More information about the Python-Dev mailing list