[issue1741130] struct.pack("I", "foo"); struct.pack("L", "foo") should fail

Mark Dickinson report at bugs.python.org
Sat Jul 4 23:48:13 CEST 2009


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

Here's a patch that does some general cleanup of the object->integer 
helper functions in the struct module;  in the process, it fixes this 
bug.  With this patch, all conversions from a PyObject to a C integer go 
through get_pylong, so they're all treated the same way.  Currently 
(i.e., without the patch) there's a lack of consistency in the way the 
various integer codes are handled---some codes emit a warning for float 
conversions and some ('q', 'Q') don't;  some codes will happily convert 
a Decimal instance, and others won't.  Some codes produce this strange 
'unsupported operand types' message and some don't, etc.

----------
versions: +Python 2.7 -Python 2.6
Added file: http://bugs.python.org/file14451/issue1741130.patch

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


More information about the Python-bugs-list mailing list