[ python-Bugs-1530559 ] struct.pack raises TypeError where it used to convert
SourceForge.net
noreply at sourceforge.net
Thu Aug 3 04:10:37 CEST 2006
Bugs item #1530559, was opened at 2006-07-28 14:07
Message generated for change (Comment added) made by etrepum
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1530559&group_id=5470
Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: Python 2.5
Status: Open
Resolution: None
Priority: 9
Submitted By: Joe Wreschnig (piman)
Assigned to: Bob Ippolito (etrepum)
Summary: struct.pack raises TypeError where it used to convert
Initial Comment:
piman at toybox:~$ python2.4 -c "import struct;
struct.pack('>H', 1.0)"
piman at toybox:~$ python2.5 -c "import struct;
struct.pack('>H', 1.0)"
Traceback (most recent call last):
File "<string>", line 1, in <module>
File "/usr/lib/python2.5/struct.py", line 63, in pack
return o.pack(*args)
TypeError: unsupported operand type(s) for &: 'float'
and 'long'
This might have appeared as part of the struct
optimizations; if struct isn't going to convert anymore
for performance reasons, I think this should be
mentioned in the release notes. Though personally I
would prefer struct go back to converting its arguments.
----------------------------------------------------------------------
>Comment By: Bob Ippolito (etrepum)
Date: 2006-08-02 22:10
Message:
Logged In: YES
user_id=139309
I've attached a patch which should resolve this issue.
----------------------------------------------------------------------
Comment By: Neal Norwitz (nnorwitz)
Date: 2006-07-28 23:21
Message:
Logged In: YES
user_id=33168
I'd like to see a deprecation warning so old code continues
to work. struct is way to loose and needs to be tightened
up, but that might not fully happen until py3k.
----------------------------------------------------------------------
Comment By: Georg Brandl (gbrandl)
Date: 2006-07-28 15:44
Message:
Logged In: YES
user_id=849994
I think that's a question for python-dev.
----------------------------------------------------------------------
Comment By: Bob Ippolito (etrepum)
Date: 2006-07-28 15:31
Message:
Logged In: YES
user_id=139309
That wasn't really intentional, but the old behavior looks a bit suspect:
$ python2.4 -c "import struct; print repr(struct.pack('>H', 1.6))"
'\x00\x01'
We could change it to check for floats and do a DeprecationWarning?
----------------------------------------------------------------------
Comment By: Georg Brandl (gbrandl)
Date: 2006-07-28 14:51
Message:
Logged In: YES
user_id=849994
Bob?
----------------------------------------------------------------------
You can respond by visiting:
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1530559&group_id=5470
More information about the Python-bugs-list
mailing list