[ python-Bugs-1483963 ] struct.unpack problem with @, =, < specifiers

SourceForge.net noreply at sourceforge.net
Wed May 10 16:30:52 CEST 2006


Bugs item #1483963, was opened at 2006-05-08 18:05
Message generated for change (Comment added) made by mwh
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1483963&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: None
Status: Open
Resolution: None
Priority: 5
Submitted By: Christian Hudon (chrish42)
Assigned to: Nobody/Anonymous (nobody)
Summary: struct.unpack problem with @, =, < specifiers

Initial Comment:
When using struct to unpack floats, I'm getting
inconsistent results when using the '<d' specification
instead of '@d' on a little-endian machine (Intel).
Here's a short python snippet that demonstrates the
problem.

import sys, struct

s = '\x00\x00\x00\x00\x00\x00\xf8\x7f'

>>> sys.byteorder
'little'

# This is correct...
>>> struct.unpack('@d', s)
(nan,)

# These should be equivalent for unpacking a single 
# double on little-endian arch... but they're not.
>>> struct.unpack('<d', s)
(inf,)
>>> struct.unpack('=d', s)
(inf,)


----------------------------------------------------------------------

>Comment By: Michael Hudson (mwh)
Date: 2006-05-10 15:30

Message:
Logged In: YES 
user_id=6656

I'm glad my fix worked.  I'm not personally inclined to port the fixes to the 2.4 
branch, as they are indeed fairly involved.

----------------------------------------------------------------------

Comment By: Christian Hudon (chrish42)
Date: 2006-05-10 15:24

Message:
Logged In: YES 
user_id=980271

I had tried with 2.3.5 and 2.4.1 and the bug was present in
both versions. I just tried with svn HEAD, and the bug is
fixed there (at least in the revision that I tried). 

It'd be nice if this bug fix could be included in the next
2.4 point release, assuming the fix is not too complicated.
Is there a process for nominating bugfixes for the main-2.4
branch?

----------------------------------------------------------------------

Comment By: Michael Hudson (mwh)
Date: 2006-05-10 13:17

Message:
Logged In: YES 
user_id=6656

Can you try Python from svn HEAD?  Or did you?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1483963&group_id=5470


More information about the Python-bugs-list mailing list