Bug in struct.calcsize() ?

J

James Lamanna

Noticed this under 2.3.3:

struct.calcsize('H') => 2
struct.calcsize('BBB') => 3
struct.calcsize('BBBH') => 6

Umm, shouldn't 'BBBH' return 5?

Please CC me for I am not subscribed.
 
A

Andrew Henshaw

James said:
Noticed this under 2.3.3:

struct.calcsize('H') => 2
struct.calcsize('BBB') => 3
struct.calcsize('BBBH') => 6

Umm, shouldn't 'BBBH' return 5?

Please CC me for I am not subscribed.
I'll also post here (for the benefit of others that might google for this
question).

In the struct documentation, there is a table for byte order and alignment.
Providing one of the characters '@=><!' as the first character of your
string specifies the byte order and alignment behavior. Since your string
doesn't specify one, then native byte order and alignment are assumed. In
this case, your C compiler aligns 16-bit ints to a 16-bit boundary. To
pack without padding, use '=' as the first character.

struct.calcsize('=BBBH') => 5
 
A

Andrew Henshaw

Andrew Henshaw wrote:

....snip...

I see you followed up to yourself with the solution! Now I just need to fix
the bug in my newsreader (knode) that allows these followups to be
scattered about the list, even though threading is turned on and sorting by
subject is specified!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,479
Members
44,899
Latest member
RodneyMcAu

Latest Threads

Top