Type discrepancy using struct.unpack

Pieter Rautenbach parautenbach at gmail.com
Thu Oct 19 10:06:33 EDT 2006


Leo Kislov wrote:
> Pieter Rautenbach wrote:
> > Hallo,
> >
> > I have a 64 bit server with CentOS 4.3 installed, running Python.
> >
> > [pymsnt at lutetium pymsnt-0.11.2]$ uname -a
> > Linux lutetium.mxit.co.za 2.6.9-34.ELsmp #1 SMP Thu Mar 9 06:23:23 GMT
> > 2006 x86_64 x86_64 x86_64 GNU/Linux
> >
> > Consider the following two snippets, issuing a struct.unpack(...) using
> > Python 2.3.4 and Python 2.5 respectively.
> >
> > [pymsnt at lutetium pymsnt-0.11.2]$ python
> > Python 2.5 (r25:51908, Oct 17 2006, 10:34:59)
> > [GCC 3.4.5 20051201 (Red Hat 3.4.5-2)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import struct
> > >>> print type(struct.unpack(">L", "xxxx")[0])
> > <type 'int'>
> > >>>
> >
> > [pymsnt at lutetium pymsnt-0.11.2]$ /usr/bin/python2.3
> > Python 2.3.4 (#1, Feb 17 2005, 21:01:10)
> > [GCC 3.4.3 20041212 (Red Hat 3.4.3-9.EL4)] on linux2
> > Type "help", "copyright", "credits" or "license" for more information.
> > >>> import struct
> > >>> print type(struct.unpack(">L", "xxxx")[0])
> > <type 'long'>
> > >>>
> >
> > I would expect <type 'long'> in both cases. Why is this not so?
>
> http://mail.python.org/pipermail/python-dev/2006-May/065199.html
> 
>   -- Leo.

Thanks a lot!




More information about the Python-list mailing list