Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2 #83097

Closed
corona10 opened this issue Nov 26, 2019 · 17 comments
Labels
3.9 only security fixes easy stdlib Python modules in the Lib dir

Comments

@corona10
Copy link
Member

BPO 38916
Nosy @brettcannon, @rhettinger, @vstinner, @benjaminp, @serhiy-storchaka, @corona10, @miss-islington
PRs
  • bpo-38916: array.array: remove fromstring() and tostring() #17487
  • [3.8] bpo-38916: Document array.array deprecation #17523
  • [3.7] bpo-38916: Document array.array deprecation (GH-17523) #17525
  • 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 = 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'

    bugs.python.org fields:

    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']

    @corona10
    Copy link
    Member Author

    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

    @corona10 corona10 added 3.9 only security fixes stdlib Python modules in the Lib dir labels Nov 26, 2019
    @corona10
    Copy link
    Member Author

    I'd like to tag this issue as an easy issue.

    @corona10 corona10 added the easy label Nov 26, 2019
    @corona10
    Copy link
    Member Author

    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.

    @brettcannon
    Copy link
    Member

    If it was documented as deprecated and raising a deprecation warning then 3.2 is definitely far enough back to warrant removing it.

    @brettcannon
    Copy link
    Member

    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.

    @rhettinger
    Copy link
    Contributor

    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.

    @brettcannon
    Copy link
    Member

    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.

    @corona10
    Copy link
    Member Author

    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?

    @brettcannon
    Copy link
    Member

    How about note it in the documentation and logging rather than removing them?

    Yep, docs and raising DeprecationWarning should be good.

    @vstinner
    Copy link
    Member

    vstinner commented Dec 6, 2019

    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/

    @vstinner
    Copy link
    Member

    vstinner commented Dec 6, 2019

    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.

    @vstinner
    Copy link
    Member

    vstinner commented Dec 6, 2019

    bpo-38897 removed usage of deprecated array.fromstring() method. Commit in master:

    386d00c

    @vstinner
    Copy link
    Member

    vstinner commented Dec 9, 2019

    New changeset 0131aba by Victor Stinner in branch 'master':
    bpo-38916: array.array: remove fromstring() and tostring() (GH-17487)
    0131aba

    @vstinner
    Copy link
    Member

    vstinner commented Dec 9, 2019

    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.

    @vstinner
    Copy link
    Member

    vstinner commented Dec 9, 2019

    New changeset 0381ea7 by Victor Stinner in branch '3.8':
    bpo-38916: Document array.array deprecation (GH-17523)
    0381ea7

    @miss-islington
    Copy link
    Contributor

    New changeset 21e1138 by Miss Islington (bot) in branch '3.7':
    bpo-38916: Document array.array deprecation (GH-17523)
    21e1138

    @vstinner
    Copy link
    Member

    vstinner commented Dec 9, 2019

    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.

    @vstinner vstinner closed this as completed Dec 9, 2019
    @vstinner vstinner changed the title Remove array.fromstring Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2 Dec 9, 2019
    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes easy stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants