classification
Title: Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, brett.cannon, corona10, miss-islington, rhettinger, serhiy.storchaka, vstinner
Priority: normal Keywords: easy (C), patch

Created on 2019-11-26 14:08 by corona10, last changed 2019-12-09 13:58 by vstinner. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 17487 merged vstinner, 2019-12-06 17:50
PR 17523 merged vstinner, 2019-12-09 13:15
PR 17525 merged miss-islington, 2019-12-09 13:47
Messages (17)
msg357495 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-11-26 14:08
array.fromstring was deprecated at 3.2

IMHO, now we can remove array.fromstring.
For my research, there is no usage on the standard library.
I 'd like to propose that let's remove array.fromstring from 3.9
msg357496 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-11-26 14:10
I'd like to tag this issue as an easy issue.
msg357497 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-11-26 14:13
For whom are interested in this issue,
Please wait until the core developer decides to approve this issue. :)
After that, we can review the PR for this issue.

Thank you for understanding.
msg357524 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-11-26 19:10
If it was documented as deprecated and raising a deprecation warning then 3.2 is definitely far enough back to warrant removing it.
msg357527 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-11-26 19:51
Although I will admit we have not had a discussion on python-dev about removing stuff that was left for Python 2.7 compatibility, so that discussion should probably occur first before we go ripping stuff out.
msg357538 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2019-11-26 22:51
Thoughts:
* The tostring() method should be handled in the same way.
* Remediation is easy because from_bytes() is a alias
* Still, all removals cause disruption from at least some users
* The only real benefit of removing it is a sense of tidiness;
  otherwise, there's no harm to keeping it (it's not broken).
* 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.
msg357576 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-11-27 17:59
> there's no harm to keeping it (it's not broken)

... for now. :) There's always the risk that will change if we keep the code around.

> 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.

If the function is left then I agree it should probably be updated to match the rest of the module.
msg357601 - (view) Author: Dong-hee Na (corona10) * (Python triager) Date: 2019-11-28 05:39
> 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 agree,
How about note it in the documentation and logging rather than removing them?
msg357623 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2019-11-28 17:25
> How about note it in the documentation and logging rather than removing them?

Yep, docs and raising DeprecationWarning should be good.
msg357932 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-06 17:43
> If it was documented as deprecated and raising a deprecation warning then 3.2 is definitely far enough back to warrant removing it.

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:
https://mail.python.org/archives/list/python-dev@python.org/thread/BRA7G4UIGGW2X7YY55KQZBOGJEYNUV6O/
msg357933 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-06 17:52
I chose to write PR 17487 even if the issue was tagged as "easy (C)", just to make sure that the change is done as soon as possible in the 3.9 dev cycle.
msg357941 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-06 19:22
bpo-38897 removed usage of deprecated array.fromstring() method. Commit in master:

https://github.com/python/cpython/commit/386d00cc341b549800776b906bfc6b20ea40c7db
msg358072 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-09 13:09
New changeset 0131aba5ae20d704b972ecd2ef0fc6c9e370a1b3 by Victor Stinner in branch 'master':
bpo-38916: array.array: remove fromstring() and tostring() (GH-17487)
https://github.com/python/cpython/commit/0131aba5ae20d704b972ecd2ef0fc6c9e370a1b3
msg358073 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-09 13:16
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."

Done.

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.
msg358084 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-09 13:46
New changeset 0381ea79ac2da03179c8512c581cac588b69cff9 by Victor Stinner in branch '3.8':
bpo-38916: Document array.array deprecation (GH-17523)
https://github.com/python/cpython/commit/0381ea79ac2da03179c8512c581cac588b69cff9
msg358087 - (view) Author: miss-islington (miss-islington) Date: 2019-12-09 13:52
New changeset 21e11383cc59146184da0d69a3f19f004215f9a7 by Miss Islington (bot) in branch '3.7':
bpo-38916: Document array.array deprecation (GH-17523)
https://github.com/python/cpython/commit/21e11383cc59146184da0d69a3f19f004215f9a7
msg358089 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-12-09 13:58
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.
History
Date User Action Args
2019-12-09 13:58:48vstinnersetstatus: open -> closed
title: Remove array.fromstring -> Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2
messages: + msg358089

resolution: fixed
stage: patch review -> resolved
2019-12-09 13:52:11miss-islingtonsetnosy: + miss-islington
messages: + msg358087
2019-12-09 13:47:02miss-islingtonsetpull_requests: + pull_request17003
2019-12-09 13:46:37vstinnersetmessages: + msg358084
2019-12-09 13:16:14vstinnersetmessages: + msg358073
2019-12-09 13:15:22vstinnersetpull_requests: + pull_request17001
2019-12-09 13:09:37vstinnersetmessages: + msg358072
2019-12-06 19:22:57vstinnersetmessages: + msg357941
2019-12-06 17:52:50vstinnersetmessages: + msg357933
2019-12-06 17:50:30vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request16966
2019-12-06 17:43:46vstinnersetmessages: + msg357932
2019-11-28 17:25:46brett.cannonsetmessages: + msg357623
2019-11-28 05:39:07corona10setmessages: + msg357601
2019-11-27 17:59:20brett.cannonsetmessages: + msg357576
2019-11-26 22:51:08rhettingersetnosy: + rhettinger
messages: + msg357538
2019-11-26 19:51:23brett.cannonsetmessages: + msg357527
2019-11-26 19:10:20brett.cannonsetmessages: + msg357524
2019-11-26 14:13:51corona10setnosy: + brett.cannon
2019-11-26 14:13:26corona10setmessages: + msg357497
2019-11-26 14:10:49corona10setkeywords: + easy (C)
2019-11-26 14:10:33corona10setmessages: + msg357496
2019-11-26 14:08:48corona10create