New submission from Roman Zeyde: Reproduction:
Python 2.7.4 (default, Apr 19 2013, 18:28:01) [GCC 4.7.3] on linux2 Type "help", "copyright", "credits" or "license" for more information. >>> import struct >>> struct.pack('!L', 0x01020304) '\x01\x02\x03\x04' >>> struct.pack('>L', 0x01020304) '\x01\x02\x03\x04' >>> struct.pack('<L', 0x01020304) '\x04\x03\x02\x01' >>> struct.pack('L', 0x01020304) '\x04\x03\x02\x01\x00\x00\x00\x00' ### WAT??? ### >>> As far as I see at the source code (http://hg.python.org/releasing/2.7.4/file/9290822f2280/Modules/_struct.c#l703), sizeof(long) is used as the size of 'L', which is equal to 8 at 64bit Linux... The problem is that the results of packing with 'L' returns 8 bytes, instead of 4 - as was expected from the documentation... ---------- components: Interpreter Core messages: 190817 nosy: Roman.Zeyde priority: normal severity: normal status: open title: struct.pack() behaves strangely for 'L' on 64bit Linux type: behavior versions: Python 2.7 _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue18169> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com