This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: struct.unpack problem with @, =, < specifiers
Type: Stage:
Components: Library (Lib) Versions:
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: chrish42, mwh
Priority: normal Keywords:

Created on 2006-05-08 17:05 by chrish42, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg28447 - (view) Author: Christian Hudon (chrish42) * Date: 2006-05-08 17:05
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,)
msg28448 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2006-05-10 12:17
Logged In: YES 
user_id=6656

Can you try Python from svn HEAD?  Or did you?
msg28449 - (view) Author: Christian Hudon (chrish42) * Date: 2006-05-10 14:24
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?
msg28450 - (view) Author: Michael Hudson (mwh) (Python committer) Date: 2006-05-10 14:30
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.
History
Date User Action Args
2022-04-11 14:56:17adminsetgithub: 43332
2006-05-08 17:05:07chrish42create