[issue20803] struct.pack_into writes 0x00 for pad bytes

2014-02-28 Thread Andrew P. Lentvorski, Jr.

New submission from Andrew P. Lentvorski, Jr.:

This code did something unexpected to me:
 a = bytearray('1234')
 a
bytearray(b'1234')
 struct.pack_into('xBxB', a, 0, 0x59, 0x5A)
 a
bytearray(b'\x00Y\x00Z')


The unexpected part was that the 'x' pad byte formatter actually *overwrote* 
the bytes to 0 rather than leaving them alone.

Not necessarily a bug, but the fact that the pad byte writes 0x00 rather than 
being untouched/ignored should be documented.

--
components: Interpreter Core
messages: 212416
nosy: bsder
priority: normal
severity: normal
status: open
title: struct.pack_into writes 0x00 for pad bytes
type: behavior
versions: Python 2.7

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20803
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com



[issue20803] struct.pack_into writes 0x00 for pad bytes

2014-02-28 Thread R. David Murray

R. David Murray added the comment:

Contrawise, I would have found it very surprising if it had not padded with 
null bytes, but yes, the docs could be explicit about it by saying that 'x' 
padding means inserting null bytes.

--
nosy: +r.david.murray

___
Python tracker rep...@bugs.python.org
http://bugs.python.org/issue20803
___
___
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com