Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2 #83097
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
assignee = None closed_at = <Date 2019-12-09.13:58:48.548> created_at = <Date 2019-11-26.14:08:48.341> labels = ['easy', 'library', '3.9'] title = 'Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2' updated_at = <Date 2019-12-09.13:58:48.547> user = 'https://github.com/corona10'
activity = <Date 2019-12-09.13:58:48.547> actor = 'vstinner' assignee = 'none' closed = True closed_date = <Date 2019-12-09.13:58:48.548> closer = 'vstinner' components = ['Library (Lib)'] creation = <Date 2019-11-26.14:08:48.341> creator = 'corona10' dependencies =  files =  hgrepos =  issue_num = 38916 keywords = ['patch', 'easy (C)'] message_count = 17.0 messages = ['357495', '357496', '357497', '357524', '357527', '357538', '357576', '357601', '357623', '357932', '357933', '357941', '358072', '358073', '358084', '358087', '358089'] nosy_count = 7.0 nosy_names = ['brett.cannon', 'rhettinger', 'vstinner', 'benjamin.peterson', 'serhiy.storchaka', 'corona10', 'miss-islington'] pr_nums = ['17487', '17523', '17525'] priority = 'normal' resolution = 'fixed' stage = 'resolved' status = 'closed' superseder = None type = None url = 'https://bugs.python.org/issue38916' versions = ['Python 3.9']
The text was updated successfully, but these errors were encountered:
... for now. :) There's always the risk that will change if we keep the code around.
If the function is left then I agree it should probably be updated to match the rest of the module.
Exactly. I'm in favor of removing fromstring() and tostring() methods right now, and update 3.7 and 3.8 documentation to mention that the methods are removed in Python 3.9, not Python 4.0.
Either do it right now, or wait the beginning of the next Python 3.x release cycle. I prefer to push some incompatible changes at the beginning of dev cycles, to get enough time to measure the feedback from users.
Brett opened a more generic discussion about the deprecation process, since PEP-602 has been accepted:
Brett Cannon: "If it was documented as deprecated and raising a deprecation warning then 3.2 is definitely far enough back to warrant removing it."
I understood that Brett is in favor of removing it.
Raymond Hettinger: "The tostring() method should be handled in the same way."
Raymond Hettinger: "Remediation is easy because from_bytes() is a alias"
For code supporting Python 2 and Python 3, it may be annoying, but Python 3.9 will only be released after Python 2 support will end. So I consider that it's an acceptable annoyance. Users can put "if six.PY3" in their code or don't support Python 3.9.
Raymond Hettinger: "Still, all removals cause disruption from at least some users"
I'm perfectly aware of that. But I consider that it's worth it. I chose to push my change early in the 3.9 development cycle, to get users feedback earlier. So we can still revert the change if they are too many complains.
Raymond Hettinger: "The other deprecation in the array module says, "Deprecated since version 3.3, will be removed in version 4.0". Perhaps this one should have had the same qualifier."
I proposed PR 17523 to document that tostring() and fromstring() deprecated aliases will be removed in Python 3.9.
The aliases were deprecated since Python 3.2. It's now time to use the newer names.
array.array.fromstring() implictly converted Unicode to UTF-8:
$ python3 Python 3.7.5 (default, Oct 17 2019, 12:16:48) >>> import array >>> a=array.array('B') >>> a.fromstring('€uro') >>> a array('B', [226, 130, 172, 117, 114, 111]) >>> list('€uro'.encode('utf8')) [226, 130, 172, 117, 114, 111]
The removal is now documented in 3.7 and 3.8.