[issue36299] array: Deprecate 'u' type in array module

2020-04-22 Thread Inada Naoki


Inada Naoki  added the comment:

While array('u') doesn't use deprecated API with GH-19653, I still don't like 
'u' because:

* I don't have any reason to use platform dependant wchar_t. [1]
* It is not consistent with PEP-3118.

[1]: https://mail.python.org/pipermail/python-dev/2019-March/156807.html

How about this plan?

* Add 'w' for Py_UCS4.
* Deprecate 'u', and remove it in the future.

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2020-04-22 Thread Terry J. Reedy


Terry J. Reedy  added the comment:

Should this issue be closed, possibly as superseded by #36346, the issue for 
the new PR-19653?

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2020-04-22 Thread Inada Naoki


Inada Naoki  added the comment:

I closed GH-12497 (Py_UNICODE -> Py_UCS4).
I created GH-19653 (Py_UNICODE -> wchar_t) instead.

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread STINNER Victor


Change by STINNER Victor :


--
nosy:  -vstinner

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread Stefan Krah


Stefan Krah  added the comment:

The funny thing is that array() already knows this:

>>> import array
>>> a = array.array("u", "123")
>>> memoryview(a).format
'w'

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread Stefan Krah


Stefan Krah  added the comment:

array() uses struct module characters except for 'u'. PEP-3118 was 
supposed to be implemented in the struct module.

If array() continues to use 'u', the only sensible thing would be
to remove (or rename) 'a', 'u' and 'w' from PEP-3118.

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread Serhiy Storchaka


Serhiy Storchaka  added the comment:

array('u') is not tied with the legacy Unicode C API. It is possible to use the 
modern wchar_t based Unicode C API for it. See issue36346.

There are benefits from getting rid of the legacy Unicode C API, but not from 
array('u').

--
nosy: +serhiy.storchaka

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread Stefan Krah


Stefan Krah  added the comment:

Just to demonstrate what the format would look like, this is working
for an array of fixed bytes:

>>> x = xnd([b"123", b"23456"], dtype="fixed_bytes(size=10)")
>>> memoryview(x).format
'10s'


So the formats in the previous message would be '10u' and '10w'.

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread Stefan Krah


Stefan Krah  added the comment:

I think the problem is still whether to use 'u' == UCS2 and 'w' == UCS4 like in 
PEP-3118.

For the project I'm currently working on I'd need these for buffer exports:

>>> from xnd import *
>>> x = xnd(["abc", "xyz"], dtype="fixed_string(10, 'utf16')")
>>> y = xnd(["abc", "xyz"], dtype="fixed_string(10, 'utf32')")
>>> 
>>> memoryview(x)
Traceback (most recent call last):
  File "", line 1, in 
ValueError: type is not supported by the buffer protocol


The use case is not an array that represents a single utf16 string, but
an array *of* fixed strings with different encodings.

So x would be exported with format 'u' and y with format 'w'.

--

___
Python tracker 

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



[issue36299] array: Deprecate 'u' type in array module

2019-03-22 Thread Inada Naoki


Change by Inada Naoki :


--
nosy: +ncoghlan, skrah, vstinner
stage: patch review -> 
title: Deprecate 'u' type in array module -> array: Deprecate 'u' type in array 
module

___
Python tracker 

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