New issue 54 by raphael.vinot: IP recognition failure
http://code.google.com/p/netaddr/issues/detail?id=54
What steps will reproduce the problem?
1. from netaddr import IPAddress
2. IPAddress('001.001.001.011') or IPAddress('001.001.001.019')
What is the expected output?
IPAddress('001.001.001.011') -> IPAddress('1.1.1.11')
IPAddress('001.001.001.019') -> IPAddress('1.1.1.19')
What do you see instead?
IPAddress('001.001.001.011') -> IPAddress('1.1.1.9')
IPAddress('001.001.001.019') -> AddrFormatError: failed to detect IP
version: '001.001.001.019'
What version of the product are you using? On what operating system?
netaddr 0.7.4 on Ubuntu 9.10
--
You received this message because you are listed in the owner
or CC fields of this issue, or because you starred this issue.
You may adjust your issue notification preferences at:
http://code.google.com/hosting/settings
a (big) list of valid address which return a AddrFormatError exception
Attachments:
ips.tar.bz2 2.8 MB
Comment #2 on issue 54 by drkjam: IP recognition failure
http://code.google.com/p/netaddr/issues/detail?id=54
Thanks for raising this ticket. Before making any decisions about how to
resolve this
I'd like some feedback.
This isn't strictly a bug/defect as I hope the following makes clear.
netaddr maintains compatibility with the inet_aton() and inet_ntoa()
function calls
exposed by the Python socket module (ultimate calling the C library
functions on your
platform).
From the inputs provided, you'll notice that octets beginning with a zero
digit are
being interpreted as octal rather than decimal values.
For example :-
>>> import socket
>>> socket.inet_aton('001.001.001.019')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
socket.error: illegal IP address string passed to inet_aton
This raises an error as '9' is not a valid octal digit.
You'll notice the exact same behaviour in your web browser or 'ping'
command :-
$ ping 001.001.001.019
ping: unknown host 001.001.001.019
Typing this IP in the address bar of your favourite web browser will issue
a warning
about your browser not being able to find the server (without actually even
trying to
contact it).
Now compare how different the behaviour is when you use the address
001.001.001.017
instead for each of the above. As you can see the results are quite
different.
Essentially the same underlying calls are being used in all cases.
Would you like to see zero-padded octets interpreted as decimal rather than
octal
values? Is this something you can live "as is" or is it something you'd
like to see
made a configurable option in a future version of the netaddr library?
that's right, I was using mostly 'whois' and the whois-servers always
interpret the
addresses as written in decimal notation and so just remove the zeros.
My problem is that I'm working with zeros-padded address in dotted decimal
notation
and it would so be very useful to have a configurable option in a future
version.
Comment #4 on issue 54 by drkjam: IP recognition failure
http://code.google.com/p/netaddr/issues/detail?id=54
OK, there is at least one use case within netaddr itself I know of (some
IANA data
parsing code) that has similar requirements. I'll have a look at
formulating a
workable solution for the 0.7.5 release.