This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author ncoghlan
Recipients georg.brandl, ncoghlan, pmoody
Date 2012-08-05.08:03:12
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1344153793.69.0.927408739195.issue15559@psf.upfronthosting.co.za>
In-reply-to
Content
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.
History
Date User Action Args
2012-08-05 08:03:13ncoghlansetrecipients: + ncoghlan, georg.brandl, pmoody
2012-08-05 08:03:13ncoghlansetmessageid: <1344153793.69.0.927408739195.issue15559@psf.upfronthosting.co.za>
2012-08-05 08:03:12ncoghlanlinkissue15559 messages
2012-08-05 08:03:12ncoghlancreate