Closed GoogleCodeExporter closed 9 years ago
ipaddr.IPv6Address('::ffff:192.168.0.0') also blows up, though in a different
way--it
throws an exception. This can be fixed by changing line 1411 from:
ip_int = (ip_int << 16) + int(field, 16)
to:
ip_int = (ip_int << 16) + int(field or '0', 16)
Original comment by rlaa...@gmail.com
on 3 Dec 2009 at 5:39
hey, thanks for the report. this should be fixed in r134.
Original comment by pmo...@google.com
on 4 Feb 2010 at 4:18
ipaddr.IPv6Address('::ffff:10.10.0.0') is still broken. I'm at r136.
Perhaps you were saying that the second case (192.168.0.0) was fixed?
Original comment by rlaa...@gmail.com
on 4 Feb 2010 at 1:34
this is what I see:
In [2]: ipaddr.IPv6Address('::ffff:10.10.0.0')
Out[2]: IPv6Address('::ffff:a0a:0')
Original comment by pmo...@google.com
on 12 Feb 2010 at 6:50
This is what I see:
In [2]: ipaddr.IPv6Address('::ffff:10.10.0.0')
Out[2]: IPv6Address('3a3a:6666:6666:3a31:302e:3130:2e30:2e30')
I'm using revision 144 on python 2.6.4 on Ubuntu 9.10 "Karmic" on i386 (well,
i686)
Linux 2.6.31-19-generic.
Original comment by rlaa...@gmail.com
on 14 Feb 2010 at 11:56
pmoody@tiny - (0) - 08:57 - ~/src/ipaddr-py/trunk
-> uname -a
Linux tiny 2.6.31-19-generic #56-Ubuntu SMP Thu Jan 28 01:26:53 UTC 2010 i686
GNU/Linux
pmoody@tiny - (0) - 08:57 - ~/src/ipaddr-py/trunk
-> python2.6
Python 2.6.4 (r264:75706, Dec 7 2009, 18:45:15)
[GCC 4.4.1] on linux2
Type "help", "copyright", "credits" or "license" for more information.
Could not open PYTHONSTARTUP
IOError: [Errno 2] No such file or directory: '/home/pmoody/.pythonrc'
>>> import ipaddr
>>> ipaddr.IPv6Address('::ffff:10.10.0.0')
IPv6Address('::ffff:a0a:0')
I'm going to forward this to the list and see if anyone there can reproduce
this.
Original comment by pmo...@google.com
on 15 Feb 2010 at 5:00
[deleted comment]
revision 144 works as expected for me on Ubuntu 9.10 karmic i686's python
2.6.4. I
get the same correct result as pmoody.
rlaager - are you sure you don't have any local differences in your ipaddr
sandbox?
Whats the result of the following code on your system?
>>> import ipaddr
>>> ipaddr.IPv6Address('::ffff:10.10.0.0')._ip
281470850170880L
If the number does not match, could you single step the execution of
_BaseV6._ip_int_from_string() printing the 'fields' list after each line
executed during
your ipaddr.IPv6Address('::ffff:10.10.0.0') call?
Otherwise if the number matches, something is apparently happening when
converting it back to a string for printing and single stepping that would be
helpful.
Original comment by gpsm...@gmail.com
on 15 Feb 2010 at 10:17
Can't reproduce on Ubuntu 8.10 (albeit x64). Attached a one-line testscript.
What is
its outputs on your machine, rlaager?
$ svn checkout -q http://ipaddr-py.googlecode.com/svn/trunk/
/tmp/ipaddr-test-strange/ && cd /tmp/ipaddr-test-strange/ && svn info | grep
Revision
&& md5sum ipaddr.py && svn status && python -c "import
ipaddr,platform;print(platform.platform());print(platform.python_implementation(
)+platform.python_version());print(repr(ipaddr.IPv6Address('::ffff:10.10.0.0')))
"
Revision: 144
eeeff9da9d42fc2515a666b69db06985 ipaddr.py
Linux-2.6.31-17-generic-x86_64-with-Ubuntu-9.10-karmic
CPython2.6.4
IPv6Address('::ffff:a0a:0')
Original comment by phihag.de@gmail.com
on 15 Feb 2010 at 10:20
Attachments:
I've gotten to the bottom of this. I'm very sorry. It was my fault. As far as I
can
tell, there's no proper way to get ipaddr to take byte representations of IP
addresses on Python 2.x. In our project's startup, we forcibly set
ipaddr._compat_has_real_bytes to True. This causes things to mostly work, but it
breaks down on '::ffff:10.10.0.0' because it's 16 characters long, so it passes
the
length test as a packed binary IPv6 address.
Original comment by rlaa...@gmail.com
on 15 Feb 2010 at 10:44
thanks for looking further into this. If there's something we can do with
ipaddr, please feel
free to file a feature request.
marking this as fixed now.
Cheers,
/peter
Original comment by pmo...@google.com
on 16 Feb 2010 at 5:06
As a workaround, replace the assignment of ipaddr._compat_has_real_bytes with
import struct
ipaddr.IPv6Address.frombytes = staticmethod(lambda bs:
ipaddr.IPv6Address(struct.unpack('!QQ', bs)[0] << 64 |
struct.unpack('!QQ',bs)[1]))
ipaddr.IPv4Address.frombytes = staticmethod(lambda bs:
ipaddr.IPv4Address(struct.unpack('!I', bs)[0]))
>>> ipaddr.IPv4Address.frombytes('\x01\x02\x03\x04')
IPv4Address('1.2.3.4')
>>>
ipaddr.IPv6Address.frombytes('\x00\x01\x00\x00\x00\x00\x00\x00\x00\x00\x00\x00\x
00\x00\x00\x01')
IPv6Address('1::1')
Original comment by phihag.de@gmail.com
on 16 Feb 2010 at 7:29
Original issue reported on code.google.com by
rlaa...@gmail.com
on 23 Nov 2009 at 8:41