google / ipaddr-py

Google's Python IP address manipulation library
Apache License 2.0
195 stars 70 forks source link

IP Addresses with Leading Zeros Fail #92

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
ipaddr.IPAddress(u'192.168.19.036') raises a ValueError. In my opinion, it 
should provide the same result as ipaddr.IPAddress(u'192.168.19.36').

I'm running r238 on Ubuntu 10.04 "Lucid" with Python 2.6.5.

Original issue reported on code.google.com by rlaa...@gmail.com on 30 Nov 2011 at 3:57

GoogleCodeExporter commented 9 years ago
I see that. this is from 
http://code.google.com/p/ipaddr-py/source/browse/trunk/ipaddr.py#1070, 
introduced in r225. I'll double check because while I agree with the comment, 
it seems like other address modules support it.

Original comment by pmo...@google.com on 30 Nov 2011 at 5:12

GoogleCodeExporter commented 9 years ago
> In my opinion, it should provide the same result as 
ipaddr.IPAddress(u'192.168.19.36').

I disagree.  On my Linux machine, "036" is parsed as an octal number:

$ ping 192.168.19.036
PING 192.168.19.036 (192.168.19.30) 56(84) bytes of data.

I think rejecting an ambiguous address is the best approach, because anything 
else is going to lead to confusion and bugs.

Original comment by pma...@google.com on 30 Nov 2011 at 7:05

GoogleCodeExporter commented 9 years ago
I forgot about the stupid octal representation. So IPAddress should either 
behave like Linux or like it does now. Either way, I'll cleanup my data.

Original comment by rlaa...@gmail.com on 30 Nov 2011 at 7:34

GoogleCodeExporter commented 9 years ago

Original comment by pmo...@google.com on 4 Dec 2011 at 9:14

GoogleCodeExporter commented 9 years ago
Issue 93 has been merged into this issue.

Original comment by pmo...@google.com on 16 Feb 2012 at 1:49