Issue 20014: Makes array.array constructor accepts ascii-unicode typecode - Python tracker

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.

classification
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: serhiy.storchaka Nosy List: alexandre.vassalotti, python-dev, serhiy.storchaka, terry.reedy, vajrasky
Priority: normal Keywords: patch

Created on 2013-12-18 09:49 by vajrasky, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
makes_array_accepts_ascii_unicode_typecode.patch vajrasky, 2013-12-18 09:49 review
makes_array_accepts_ascii_unicode_typecode_v2.patch vajrasky, 2013-12-18 10:16 review
makes_array_accepts_ascii_unicode_typecode_v3.patch vajrasky, 2013-12-19 02:36 review
Messages (10)
msg206503 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-12-18 09:49
>>> import array
>>> array.array(u'i', [1,2,3])
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: must be char, not unicode

In this ticket #13566, Alexandre Vassalotti said:
"We should still fix array in 2.7 to accept unicode object for the typecode though."

So here is the patch to add support for ascii-unicode typecode for array.array constructor.
msg206505 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-12-18 10:13
Here is the patch with simpler unittest.
msg206516 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-18 13:10
I think a patch can be much simpler. Perhaps make "c" to accept 1-character Unicode objects?
msg206531 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2013-12-18 16:00
See issue20015 for more general and simple solution.
msg206571 - (view) Author: Vajrasky Kok (vajrasky) * Date: 2013-12-19 02:36
Thanks, Serhiy, for the review! Here is the patch to avoid refleaking and avoid literal u'' string.

If your ticket, #20015, is accepted, then we can throw away the fix and use only unit test in this ticket.
msg206720 - (view) Author: Terry J. Reedy (terry.reedy) * (Python committer) Date: 2013-12-21 00:12
This enhancement request would have been nice in 2.7.0 but it is too late for bugfix releases. Typecodes have always been shown as instances of str and still are. The doc no where suggests that unicode chars should work in 2.7 and it is not a bug that they do not.
msg212613 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2014-03-03 07:31
Re-opened due to Python-Dev discussion http://comments.gmane.org/gmane.comp.python.devel/146057.
msg243321 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-16 14:13
New changeset 7d60cb6c33cf by Serhiy Storchaka in branch '2.7':
Issue #20014: array.array() now accepts unicode typecodes.  Based on patch by
https://hg.python.org/cpython/rev/7d60cb6c33cf
msg243465 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2015-05-18 08:31
Committed simplified version. Thank you Vajrasky for your patch.
msg244528 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2015-05-31 08:57
New changeset 6ee122fac1e8 by Serhiy Storchaka in branch '2.7':
Fixed the array module in unicode disabled build (regression of issue20014).
https://hg.python.org/cpython/rev/6ee122fac1e8