[Python-Dev] cpython: Close #15559: Implementing __index__ creates a nasty interaction with the bytes

Antoine Pitrou solipsis at pitrou.net
Sun Aug 5 15:00:04 CEST 2012


On Sun,  5 Aug 2012 10:20:36 +0200 (CEST)
nick.coghlan <python-checkins at python.org> wrote:

> http://hg.python.org/cpython/rev/5abea8a43f19
> changeset:   78426:5abea8a43f19
> user:        Nick Coghlan <ncoghlan at gmail.com>
> date:        Sun Aug 05 18:20:17 2012 +1000
> summary:
>   Close #15559: Implementing __index__ creates a nasty interaction with the bytes constructor. At least for 3.3, ipaddress objects must now be explicitly converted with int() and thus can't be passed directly to the hex() builtin.

__index__, as the name implies, allows instances to be used as sequence
indices, which does sound like a weird thing to serve as for an IP
address :-)

Regards

Antoine.


-- 
Software development and contracting: http://pro.pitrou.net




More information about the Python-Dev mailing list