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 base64.encodestring() and base64.decodestring() aliases, deprecated since Python 3.1 #83532

Closed
vstinner opened this issue Jan 16, 2020 · 3 comments
Labels
3.9 only security fixes stdlib Python modules in the Lib dir

Comments

@vstinner
Copy link
Member

BPO 39351
Nosy @vstinner
PRs
  • bpo-39351: Remove base64.encodestring() #18022
  • 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 2020-01-16.09:24:34.194>
    created_at = <Date 2020-01-16.08:25:17.167>
    labels = ['library', '3.9']
    title = 'Remove base64.encodestring() and base64.decodestring() aliases, deprecated since Python 3.1'
    updated_at = <Date 2020-01-16.09:24:34.193>
    user = 'https://github.com/vstinner'

    bugs.python.org fields:

    activity = <Date 2020-01-16.09:24:34.193>
    actor = 'vstinner'
    assignee = 'none'
    closed = True
    closed_date = <Date 2020-01-16.09:24:34.194>
    closer = 'vstinner'
    components = ['Library (Lib)']
    creation = <Date 2020-01-16.08:25:17.167>
    creator = 'vstinner'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 39351
    keywords = ['patch']
    message_count = 3.0
    messages = ['360096', '360097', '360102']
    nosy_count = 1.0
    nosy_names = ['vstinner']
    pr_nums = ['18022']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = None
    url = 'https://bugs.python.org/issue39351'
    versions = ['Python 3.9']

    @vstinner
    Copy link
    Member Author

    base64.encodestring() and base64.decodestring() are aliases deprecated since Python 3.1: encodebytes() and decodebytes() should be used instead.

    In Python 3, "string" means Unicode, whereas these functions really work at the bytes level:

    >>> base64.encodestring("text")
    TypeError: expected bytes-like object, not str
    
    >>> base64.decodestring("text")
    TypeError: expected bytes-like object, not str

    encodebytes() and decodebytes() names are explicit on the expected types (bytes or bytes-like).

    This issue is similar to bpo-38916: "Remove array.fromstring() and array.tostring() aliases, deprecated since Python 3.2".

    Attached PR removes the deprecated aliases base64.encodestring() and base64.decodestring().

    @vstinner vstinner added 3.9 only security fixes stdlib Python modules in the Lib dir labels Jan 16, 2020
    @vstinner
    Copy link
    Member Author

    The deprecation was introduced 11 years ago in bpo-3613 by this change:

    commit b54d801
    Author: Georg Brandl <georg@python.org>
    Date: Thu Jun 4 09:11:51 2009 +0000

    bpo-3613: add base64.encodebytes and decodebytes as the new spelling of encodestring and decodestring; deprecate the latter.
    

    The aliases were deprecated for 7 cycles (Python 3.1 to Python 3.8).

    @vstinner
    Copy link
    Member Author

    New changeset 210c19e by Victor Stinner in branch 'master':
    bpo-39351: Remove base64.encodestring() (GH-18022)
    210c19e

    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    3.9 only security fixes stdlib Python modules in the Lib dir
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant