[Python-Dev] struct module docs vs reality

Gregory P. Smith greg at krypto.org
Wed Jan 23 22:53:53 CET 2008


On 1/23/08, Thomas Heller <theller at ctypes.org> wrote:
>
> Gregory P. Smith schrieb:
> > The documentation for the struct module says:
> >
> >  http://docs.python.org/dev/library/struct.html#module-struct
> >
> >  "short is 2 bytes; int and long are 4 bytes; long long (__int64 on
> Windows)
> > is 8 bytes"
> >
> > and lists 'l' and 'L' as the pack code for a C long.
> >
> > As its implemented today, the documentation is incorrect.  On an LP64
> host
> > (pretty much any 64-bit linux, bsd or unixish thing) a long is 8 bytes.
> >
> > I assume this means there is existing code out there that expects the
> > current not-as-documented behavior.  There is also code out there that
> > expects the documented behavior but behaves wrong when a 64bit Python is
> > used.
> >
> > I assume I should just fix the documentation and anything in Lib that
> uses
> > the struct module incorrectly (zipfile for example) rather than change
> the
> > behavior?
>
> +1 (actually +100) from me.
>
> Thomas


Ok, its a pretty big diff.  Much of the standard library is completely
broken when used on LP64 platforms.  I added it to the bug.  I'm running
unit tests now.  These fixes should go into 2.5.2.

The diff could use some eyes on it, especially the Mac API stuff that I know
nothing about but am assuming relies on 32bit values.

 http://bugs.python.org/issue1789

Greg
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.python.org/pipermail/python-dev/attachments/20080123/d52b5990/attachment-0001.htm 


More information about the Python-Dev mailing list