Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > Python > Bug in struct.calcsize() ?

Reply
Thread Tools

Bug in struct.calcsize() ?

 
 
James Lamanna
Guest
Posts: n/a
 
      04-08-2004
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.

--
James Lamanna


 
Reply With Quote
 
 
 
 
Andrew Henshaw
Guest
Posts: n/a
 
      04-09-2004
James Lamanna wrote:

> 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

--
Andy
 
Reply With Quote
 
 
 
 
Andrew Henshaw
Guest
Posts: n/a
 
      04-09-2004
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!

--
Andy
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
*bug* *bug* *bug* David Raleigh Arnold Firefox 12 04-02-2007 03:13 AM
ASP.NET Login control bug or SQL 2005 bug? RedEye ASP .Net 2 12-13-2005 10:57 AM
Re: BUG? OR NOT A BUG? John ASP .Net 2 09-21-2005 10:31 AM
Bug Parade Bug 4953793 Michel Joly de Lotbiniere Java 4 12-02-2003 05:05 AM
how to report bug to g++ ? got a bug and fixed up source code DarkSpy C++ 4 06-27-2003 09:05 AM



Advertisments