classification
Title: Makes array.array constructor accepts ascii-unicode typecode
Type: enhancement Stage: resolved
Components: Extension Modules Versions: Python 2.7
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 2015-05-31 08:57 by python-dev. 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
History
Date User Action Args
2015-05-31 08:57:31python-devsetmessages: + msg244528
2015-05-18 08:31:38serhiy.storchakasetstatus: open -> closed
resolution: fixed
messages: + msg243465

stage: patch review -> resolved
2015-05-16 14:13:25python-devsetnosy: + python-dev
messages: + msg243321
2015-05-11 07:54:17serhiy.storchakasetassignee: serhiy.storchaka
2014-03-03 07:32:00serhiy.storchakasetstatus: closed -> open
resolution: out of date -> (no value)
messages: + msg212613

stage: resolved -> patch review
2013-12-21 00:12:18terry.reedysetstatus: open -> closed

type: behavior -> enhancement

nosy: + terry.reedy
messages: + msg206720
resolution: out of date
stage: patch review -> resolved
2013-12-20 23:39:23terry.reedysetstage: patch review
2013-12-19 02:36:37vajraskysetfiles: + makes_array_accepts_ascii_unicode_typecode_v3.patch

messages: + msg206571
2013-12-18 16:00:59serhiy.storchakasetmessages: + msg206531
2013-12-18 13:10:28serhiy.storchakasetnosy: + serhiy.storchaka
messages: + msg206516
2013-12-18 10:16:19vajraskysetfiles: + makes_array_accepts_ascii_unicode_typecode_v2.patch
2013-12-18 10:16:07vajraskysetfiles: - makes_array_accepts_ascii_unicode_typecode_v2.patch
2013-12-18 10:13:11vajraskysetfiles: + makes_array_accepts_ascii_unicode_typecode_v2.patch

messages: + msg206505
2013-12-18 09:49:55vajraskycreate