[Python-bugs-list] [ python-Bugs-789667 ] struct.calcsize("5BH") gives wrong result

SourceForge.net noreply at sourceforge.net
Sat Aug 16 09:52:39 EDT 2003


Bugs item #789667, was opened at 2003-08-16 04:29
Message generated for change (Comment added) made by tim_one
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=789667&group_id=5470

Category: Python Library
>Group: Not a Bug
>Status: Closed
>Resolution: Invalid
Priority: 5
Submitted By: Sinitsyn Valentine (valentine)
Assigned to: Nobody/Anonymous (nobody)
Summary: struct.calcsize("5BH") gives wrong result

Initial Comment:
Consider the following program:
import struct
print struct.calcsize("5BH")
print struct.calcsize("6BH")

One could expect that the ouptut of this program will
consist of two different numbers, 7 and 8. But this is
not the case: the program prints 8 and 8. This prevents
my Python 2.3 for Windows from unpacking strings using
"5BH" format properly.

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

>Comment By: Tim Peters (tim_one)
Date: 2003-08-16 11:52

Message:
Logged In: YES 
user_id=31435

You need to read the docs for the struct module more 
carefully, paying attention to the difference between "native" 
size and alignment (the default) and "standard" size and 
alignment (which is probably what you want, but aren't asking 
for).

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

Comment By: Thomas Heller (theller)
Date: 2003-08-16 10:11

Message:
Logged In: YES 
user_id=11105

Are you sure you didn't mean "=5BH" and "=7BH"?
This should give the desired result 7 and 8...

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

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



More information about the Python-bugs-list mailing list