You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
array: Add 'w' type and deprecate 'u' type. #80480
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2019-03-15.05:50:02.657>labels= ['3.8', 'library']
title="array: Deprecate 'u' type in array module"updated_at=<Date2020-04-23.00:47:43.731>user='https://github.com/methane'
'4.0' is a stand-in for 'sometime after 2.7.final', scheduled for Jan 2020. A Pending... for 3.8.0, scheduled for Oct 2019, seems reasonable to me. Perhaps we should have a pydev discussion for the general issue of post 2.7 removals of already deprecated items.
changed the title [-]Deprecate 'u' type in array module[/-][+]array: Deprecate 'u' type in array module[/+]on Mar 22, 2019
skrah commented on Mar 22, 2019
skrahmannequin
Mannequin
More actions
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 "<stdin>", line 1, in <module>
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'.
skrah commented on Mar 22, 2019
skrahmannequin
Mannequin
More actions
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'.
I dislike the fact that array.array('u') is only deprecated in the doc. I would prefer to either emit a DeprecationWarning at runtime, or remove the deprecation. See also issue #105373. I'm fine with really deprecating it if someone wants to submit a PR (@methane ?).
Activity
methane commentedon Mar 15, 2019
The doc says:
But DeprecationWarning is not raised yet. Let's raise it.
terryjreedy commentedon Mar 15, 2019
'4.0' is a stand-in for 'sometime after 2.7.final', scheduled for Jan 2020. A Pending... for 3.8.0, scheduled for Oct 2019, seems reasonable to me. Perhaps we should have a pydev discussion for the general issue of post 2.7 removals of already deprecated items.
methane commentedon Mar 22, 2019
https://mail.python.org/pipermail/python-dev/2019-March/156807.html
We may able to convert 'u' to wchar_t to int32_t and un-deprecate it.
methane commentedon Mar 22, 2019
I found converting Py_UNICODE to Py_UCS4 wad happened, and reverted.
ref: https://bugs.python.org/issue13072
[-]Deprecate 'u' type in array module[/-][+]array: Deprecate 'u' type in array module[/+]skrah commentedon Mar 22, 2019
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:
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'.
skrah commentedon Mar 22, 2019
Just to demonstrate what the format would look like, this is working
for an array of fixed bytes:
So the formats in the previous message would be '10u' and '10w'.
serhiy-storchaka commentedon Mar 22, 2019
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 bpo-36346.
There are benefits from getting rid of the legacy Unicode C API, but not from array('u').
skrah commentedon Mar 22, 2019
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.
skrah commentedon Mar 22, 2019
The funny thing is that array() already knows this:
methane commentedon Apr 22, 2020
I closed #56706 (Py_UNICODE -> Py_UCS4).
I created #63852 (Py_UNICODE -> wchar_t) instead.
terryjreedy commentedon Apr 22, 2020
Should this issue be closed, possibly as superseded by bpo-36346, the issue for the new PR-19653?
methane commentedon Apr 23, 2020
While array('u') doesn't use deprecated API with #63852, I still don't like 'u' because:
How about this plan?
20 remaining items
encukou commentedon May 9, 2023
How about:
'w'for Py_UCS4.wreach end of life'u', and remove it in the future.Is there a reason to rush this?
methane commentedon May 10, 2023
array('u')will cause bugs and almost no valid use case for it.So waiting deprecation 5+ years seems too slow.
On the other hand, I don't hurry about removing it.
I can wait 3+ releases instead of minimum 2 releases.
My plan is:
[-]array: Deprecate 'u' type in array module[/-][+]array: Add 'w' type and deprecate 'u' type.[/+]gh-80480: array: Add 'w' typecode. (#105242)
vstinner commentedon Jun 6, 2023
@methane added
array.array('w')format to Python 3.13.@methane: Would you mind to also document the addition with
versionchangedin https://docs.python.org/dev/library/array.html ? Currently, it's only documented at: https://docs.python.org/dev/whatsnew/3.13.html#arrayvstinner commentedon Jun 6, 2023
I dislike the fact that
array.array('u')is only deprecated in the doc. I would prefer to either emit a DeprecationWarning at runtime, or remove the deprecation. See also issue #105373. I'm fine with really deprecating it if someone wants to submit a PR (@methane ?).hugovk commentedon Jun 6, 2023
@vstinner PR already open at #95760 :)
gh-80480: Emit DeprecationWarning for array's 'u' type code (#95760)
hugovk commentedon Jun 11, 2023
Done in #105242 and #95760.
Let's close this issue and come back to this in four years.
pythongh-80480: remove deprecated 'u' type code (array)
gh-80480: Remove deprecated 'u' array type code (#149535)
vstinner commentedon Jun 1, 2026
The
arrayutype has been removed by the PR gh-149535.