Title: the struct example should give consistent results across different hardware platforms
Type: enhancement Stage: resolved
Components: Documentation Versions: Python 3.2, Python 3.3, Python 2.7
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, mark.dickinson, meador.inge, tshepang
Priority: normal Keywords:

Created on 2012-05-09 13:51 by tshepang, last changed 2012-05-09 14:15 by meador.inge. This issue is now closed.

Messages (3)
msg160291 - (view) Author: Tshepang Lekhonkhobe (tshepang) * Date: 2012-05-09 13:51
This example [1] assumes you are using a specific platform to check it out. I am using amd64, and I get different results. To fix, I prefix the format string with '>':

pack('hhl', 1, 2, 3)

pack('>hhl', 1, 2, 3)

msg160292 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2012-05-09 14:07
And the examples make an explicit note of that:

.. note::
All examples assume a native byte order, size, and alignment with a
big-endian machine.

AMD64 is little-endian;  the examples are noted to be in big-endian.

Is that note not sufficient?
msg160293 - (view) Author: Tshepang Lekhonkhobe (tshepang) * Date: 2012-05-09 14:11
Sadly, I noticed it only after submitting this report.
Date User Action Args
2012-05-09 14:15:14meador.ingesetstatus: open -> closed
resolution: not a bug
stage: resolved
2012-05-09 14:11:21tshepangsetmessages: + msg160293
2012-05-09 14:07:14meador.ingesetmessages: + msg160292
2012-05-09 13:51:51tshepangcreate