This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Title: Remove base64.encodestring() and base64.decodestring() aliases, deprecated since Python 3.1
Type: Stage: resolved
Components: Library (Lib) Versions: Python 3.9
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: vstinner
Priority: normal Keywords: patch

Created on 2020-01-16 08:25 by vstinner, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 18022 merged vstinner, 2020-01-16 08:30
Messages (3)
msg360096 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-16 08:25
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().
msg360097 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-16 08:32
The deprecation was introduced 11 years ago in bpo-3613 by this change:

commit b54d801280e3f510782e2855504710947d10f053
Author: Georg Brandl <>
Date:   Thu Jun 4 09:11:51 2009 +0000

    #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).
msg360102 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2020-01-16 09:24
New changeset 210c19e3c5b86535a73487fa737752de8eb1d866 by Victor Stinner in branch 'master':
bpo-39351: Remove base64.encodestring() (GH-18022)
Date User Action Args
2022-04-11 14:59:25adminsetgithub: 83532
2020-01-16 09:24:34vstinnersetstatus: open -> closed
resolution: fixed
stage: patch review -> resolved
2020-01-16 09:24:20vstinnersetmessages: + msg360102
2020-01-16 08:32:40vstinnersetmessages: + msg360097
2020-01-16 08:30:48vstinnersetkeywords: + patch
stage: patch review
pull_requests: + pull_request17418
2020-01-16 08:25:17vstinnercreate