[issue15035] array.array of UCS2 values

Ronald Oussoren report at bugs.python.org
Thu Aug 16 14:09:01 CEST 2012


Ronald Oussoren added the comment:

Py_UNICODE is an typedef for wchar_t and that type is 4 bytes long:

>>> a.tobytes()
b'h\x00\x00\x00e\x00\x00\x00l\x00\x00\x00l\x00\x00\x00o\x00\x00\x00 \x00\x00\x00w\x00\x00\x00o\x00\x00\x00r\x00\x00\x00l\x00\x00\x00d\x00\x00\x00'
>>> a = array.array('u', 'bar')
>>> a.tobytes()
b'b\x00\x00\x00a\x00\x00\x00r\x00\x00\x00'
>>> len(a.tobytes())
12
>>> 

This is with a checkout that was created yesterday.

The issue is not resolved, there now is no way to easily create a UCS2 buffer; while there was in earlier releases of Python (with the default narrow build)

----------

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


More information about the Python-bugs-list mailing list