[ python-Bugs-1530559 ] struct.pack raises TypeError where it used to convert

SourceForge.net noreply at sourceforge.net
Fri Jul 28 21:44:50 CEST 2006


Bugs item #1530559, was opened at 2006-07-28 18:07
Message generated for change (Comment added) made by gbrandl
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: 5
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: Georg Brandl (gbrandl)
Date: 2006-07-28 19: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 19: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 18: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