[New-bugs-announce] [issue3481] Length of struct.pack('HL', 1, 1) incorrect (8 instead of 6 bytes)

Dominique Parolin report at bugs.python.org
Fri Aug 1 02:17:05 CEST 2008


New submission from Dominique Parolin <d.parolin at gmx.net>:

Python Versions tested:
Windows 2.5.2 (r252:60911)
Debian Linux Python 2.4.4 

Example:
>>> import struct
>>> struct.pack('HL', 1, 1)

results in '\x01\x00\x00\x00\x01\x00\x00\x00'
although '\x01\x00\x01\x00\x00\x00' was expected.

if concatenated or done separately
>>> struct.pack('H', 1) + struct.pack('L', 1) 

result is as expected '\x01\x00\x01\x00\x00\x00'
or
'\x01\x00' and '\x01\x00\x00\x00' respectively

Error:
Length is 8 where it should be 6
This is as well true for "hl", "hL" and "Hl".


Free description:
I could not find another error regarding that, nor any information using
popular search.
Further no explanation found why that might be valid behaviour.

Regards,
Dominique

----------
components: Library (Lib)
messages: 70535
nosy: dparolin
severity: normal
status: open
title: Length of struct.pack('HL', 1,1) incorrect (8 instead of 6 bytes)
type: behavior
versions: Python 2.4, Python 2.5

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue3481>
_______________________________________


More information about the New-bugs-announce mailing list