Type discrepancy using struct.unpack

P

Pieter Rautenbach

Hallo,

I have a 64 bit server with CentOS 4.3 installed, running Python.

[pymsnt@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@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])

[pymsnt@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])

I would expect <type 'long'> in both cases. Why is this not so?

Regards
Pieter Rautenbach
 
L

Leo Kislov

Pieter said:
Hallo,

I have a 64 bit server with CentOS 4.3 installed, running Python.

[pymsnt@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@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])

[pymsnt@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])

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.
 
P

Pieter Rautenbach

Leo said:
Pieter said:
Hallo,

I have a 64 bit server with CentOS 4.3 installed, running Python.

[pymsnt@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@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])

[pymsnt@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])

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!
 

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,765
Messages
2,569,568
Members
45,042
Latest member
icassiem

Latest Threads

Top