[issue7355] Struct incorrectly compiles format strings

2010-05-22 Thread Mark Dickinson
Mark Dickinson added the comment: Doc changes merged in r81477 (release26-maint) and r81480 (release31-maint). -- resolution: -> fixed status: open -> closed ___ Python tracker

[issue7355] Struct incorrectly compiles format strings

2010-04-12 Thread Meador Inge
Meador Inge added the comment: Those last two sentences where meant to be in response to your "Merged your changes and subsequent tweaks to py3k in r80016." comment. I tried to reply to the tracker from my mail client and things got reformatted :( --

[issue7355] Struct incorrectly compiles format strings

2010-04-12 Thread Meador Inge
Meador Inge added the comment: > Sure, if you want to. [Then I won't be able to reproduce what's in the > docs on either of my machines. :) One's 32-bit big-endian; the other's > 64-bit little-endian.] > I guess it's painful either way. I think the only fair thing to do is provide examples

[issue7355] Struct incorrectly compiles format strings

2010-04-12 Thread Mark Dickinson
Mark Dickinson added the comment: Sure, if you want to. [Then I won't be able to reproduce what's in the docs on either of my machines. :) One's 32-bit big-endian; the other's 64-bit little-endian.] Merged your changes and subsequent tweaks to py3k in r80016. -- _

[issue7355] Struct incorrectly compiles format strings

2010-04-12 Thread Meador Inge
Meador Inge added the comment: > wonder whether they should be converted to little-endian I thought about that as well. It sure would make creating new examples easier :) I had to construct the new examples "by hand". I can regenerate the examples for little-endian if you would like? -

[issue7355] Struct incorrectly compiles format strings

2010-04-12 Thread Mark Dickinson
Mark Dickinson added the comment: Hmm. I note that the examples are for a big-endian machine. I wonder whether they should be converted to little-endian, given that most users are on x86 or x86_64 hardware these days. -- ___ Python tracker

[issue7355] Struct incorrectly compiles format strings

2010-04-12 Thread Mark Dickinson
Mark Dickinson added the comment: Many thanks for the patch. Applied (minus trailing whitespace :) in r80013. Leaving open to remind me to merge to other branches. -- versions: -Python 2.7 ___ Python tracker ___

[issue7355] Struct incorrectly compiles format strings

2010-04-10 Thread Meador Inge
Meador Inge added the comment: > would be to add enough padding so that the alignment of the struct > matches the largest alignment of any member of the struct. That might work. I will have to think about it a bit. > On the subject of documentation Attached a doc patch which addresses Mark

[issue7355] Struct incorrectly compiles format strings

2010-04-10 Thread Mark Dickinson
Mark Dickinson added the comment: > When and why things are padded usually depends on the compiler, OS, > and computer architecture. [...] Sure. The struct module has a rather simplistic set of rules for adding padding, but I believe that it manages to match the platform's C rules (assuming

[issue7355] Struct incorrectly compiles format strings

2010-04-10 Thread Meador Inge
Meador Inge added the comment: > I'm half-convinced that struct.pack *should* ideally add trailing > padding in the same situation that C does, for consistency with C. > Then calcsize would match C's sizeof. Maybe... AFAIK, the C language does not mandate structure padding. Section 6.7.2.1

[issue7355] Struct incorrectly compiles format strings

2010-04-10 Thread Meador Inge
Changes by Meador Inge : -- nosy: +minge ___ Python tracker ___ ___ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Mark Dickinson
Mark Dickinson added the comment: I'm half-convinced that struct.pack *should* ideally add trailing padding in the same situation that C does, for consistency with C. Then calcsize would match C's sizeof. If you're writing or reading a struct from C, it's probably easiest/most natural to wr

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Mark Dickinson
Mark Dickinson added the comment: > Just for clarification, why does "ci" get padded but "ic" doesn't? Because no padding is necessary in the second case: both the integer and the character already start at a position that's a multiple of 4---the integer at position 0 and the character at po

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Eric Smith
Eric Smith added the comment: It's basically because nothing comes after it. If you put something after it, such as a zero length integer, you'll see: >>> from struct import calcsize >>> calcsize("ci") 8 >>> calcsize("ic") 5 >>> calcsize("ic0i") 8 -- __

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Steve Krenzel
Steve Krenzel added the comment: Just for clarification, why does "ci" get padded but "ic" doesn't? While I agree that updating the documentation would help clarify, perhaps either everything should be padded to word boundaries or nothing should. It is weird behavior that "ic" != "ci". If bo

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Mark Dickinson
Mark Dickinson added the comment: Reopening for possible doc clarification. Suggestions welcome! -- assignee: -> mark.dickinson components: +Documentation, Extension Modules -Library (Lib) keywords: +easy priority: -> low resolution: invalid -> stage: committed/rejected -> needs pat

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Mark Dickinson
Mark Dickinson added the comment: What Eric said. You can see the padding explicitly in the results of struct.pack: >>> struct.pack("ci", '*', 0x12131415) # 8-byte result, 3 padding bytes '*\x00\x00\x00\x15\x14\x13\x12' >>> struct.pack("ic", 0x12131415, '*') # 5-byte result, no padding. '\x15\

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Eric Smith
Eric Smith added the comment: It's a padding issue, having to do with putting values at the correct word boundaries. -- nosy: +eric.smith resolution: -> invalid stage: -> committed/rejected status: open -> closed ___ Python tracker

[issue7355] Struct incorrectly compiles format strings

2009-11-19 Thread Steve Krenzel
New submission from Steve Krenzel : The struct module has a calcsize() method which reports the size of the data for a specified format string. In some instances, to the best of my knowledge, this is wrong. To repro: >>> from struct import calcsize >>> calcsize("ci") 8 >>> calcsize("ic") 5 Th