[New-bugs-announce] [issue15035] array.array of UCS2 values

Ronald Oussoren report at bugs.python.org
Fri Jun 8 11:22:50 CEST 2012


New submission from Ronald Oussoren <ronaldoussoren at mac.com>:

I'm sometimes using an array.array with format character "u" as a writable backing store for buffers shared with platform APIs that access buffers of UCS2 values. This works fine in python 3.2 and earlier with a ucs2 build of python, but no longer works with python 3.3 because the "u" character explicitly selects a UCS4 representation in that version.

An example of how I use this is using PyObjC on MacOSX, for example:

b = array.array('u', "hello world")
s = CFStringCreateMutableWithExternalCharactersNoCopy(                      
        None, b, len(b), len(b), kCFAllocatorNull)

"s" now refers to a mutable Objective-C string that uses "b" as its backing store.

It would be nice if there were a format code that would allow me to do this with Python 3.3, for example   b = array.array("U", ...)


(BTW. I'm sorry if this is a duplicate, searching for "array.array" on the tracker results in a lot of hits, most of which have nothing to do with the array module)

----------
components: Extension Modules
messages: 162520
nosy: ronaldoussoren
priority: low
severity: normal
status: open
title: array.array of UCS2 values
type: behavior
versions: Python 3.3

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


More information about the New-bugs-announce mailing list