This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author skrah
Recipients loewis, ncoghlan, skrah, teoliphant
Date 2012-08-16.11:34:16
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <20120816113418.GA14971@sleipnir.bytereef.org>
In-reply-to <20120816125729.Horde.5GaUHdjz9kRQLNIZNywB4EA@webmail.df.eu>
Content
Martin v. Loewis <report@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
bytes:

>>> import array
>>> a = array.array('u', "ABC")
>>> x = memoryview(a)
>>> a[0] == x[0]
False
>>> a[0]
'A'

# Indexing returns bytes instead of str:
>>> x[0]
b'A\x00'
>>> 

# Index assignment attempts to do slice assignment:
>>> x[0] = '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.
History
Date User Action Args
2012-08-16 11:34:17skrahsetrecipients: + skrah, loewis, teoliphant, ncoghlan
2012-08-16 11:34:17skrahlinkissue15625 messages
2012-08-16 11:34:16skrahcreate