[issue15625] Support u and w codes in memoryview
report at bugs.python.org
Thu Aug 16 13:34:17 CEST 2012
Stefan Krah added the comment:
Martin v. Loewis <report at bugs.python.org> wrote:
> I would be fine with deprecating the 'u' type arrays, acknowledging
> that the Py_UNICODE element type is even more useless now than before.
> If that is done, there is no point in fixing anything about it. If
> it exports using the 'u' and 'w' codes - fine. If then memoryview
> doesn't work properly - fine; this is a deprecated feature.
>From the perspective of memoryview backwards compatibility, deprecation is fine.
In 3.2, memoryview could really only handle one-dimensional buffers of unsigned
>>> import array
>>> a = array.array('u', "ABC")
>>> x = memoryview(a)
>>> a == x
# Indexing returns bytes instead of str:
# Index assignment attempts to do slice assignment:
>>> x = 'Z'
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'str' does not support the buffer interface
I'm +1 for deprecating 'u' and 'w' in the array module, accept that memoryview
cannot handle 'u' and 'w' and fix the situation properly in 3.4. I agree that
the latter would require people to come up with actual use cases.
Python tracker <report at bugs.python.org>
More information about the Python-bugs-list