[issue1530559] struct.pack raises TypeError where it used to convert

Mark Dickinson report at bugs.python.org
Mon Mar 1 21:09:18 CET 2010


Mark Dickinson <dickinsm at gmail.com> added the comment:

More or less, yes:  when trying to pack a non-integer `x` (i.e. something that's not an instance of int or long) with an integer format code (one of 'bBhHiIlLqQ', or 'P'), `x.__index__()` would be called to convert `x` to an integer, and that integer would be packed as usual (possibly raising OverflowError).  Other format codes wouldn't be affected.

I'm not quite sure what you mean by 'beforehand':  the conversion would happen at the same time as it currently does.

It might be a struggle for me to get to this before the 2.7 betas.  If anyone's interested in submitting a patch, it would be welcome.

----------
stage: committed/rejected -> needs patch

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue1530559>
_______________________________________


More information about the Python-bugs-list mailing list