Message167474
I've been tinkering with the ipaddress module as I review Eli's documentation and have uncovered a *very* nasty interaction between ipaddress objects and the bytes constructor.
Specifically, if you pass an integer to bytes() it will attempt to allocate and zero-initialise a buffer of that size. It uses operator.index() to check for integers.
This creates a problem, because ipaddress objects currently implement __index__ so they can be treated as integers without an explicit cast.
This does very bad things if, say, you do "bytes(ipaddress.IPv4Address('192.168.0.1'))"
If I remove the __index__ implementation, then you can't call hex() directly on ipaddress objects anymore - you have to call hex(int(addr)) instead.
I'm a *lot* happier with that approach, and will be implementing it in a moment. |
|
Date |
User |
Action |
Args |
2012-08-05 08:03:13 | ncoghlan | set | recipients:
+ ncoghlan, georg.brandl, pmoody |
2012-08-05 08:03:13 | ncoghlan | set | messageid: <1344153793.69.0.927408739195.issue15559@psf.upfronthosting.co.za> |
2012-08-05 08:03:12 | ncoghlan | link | issue15559 messages |
2012-08-05 08:03:12 | ncoghlan | create | |
|