Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 210c19e

Browse filesBrowse files
authored
bpo-39351: Remove base64.encodestring() (GH-18022)
Remove base64.encodestring() and base64.decodestring(), aliases deprecated since Python 3.1: use base64.encodebytes() and base64.decodebytes() instead.
1 parent fad8b56 commit 210c19e
Copy full SHA for 210c19e

File tree

Expand file treeCollapse file tree

5 files changed

+8
-36
lines changed
Filter options
Expand file treeCollapse file tree

5 files changed

+8
-36
lines changed

‎Doc/library/base64.rst

Copy file name to clipboardExpand all lines: Doc/library/base64.rst
-12Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -235,12 +235,6 @@ The legacy interface:
235235

236236
.. versionadded:: 3.1
237237

238-
.. function:: decodestring(s)
239-
240-
Deprecated alias of :func:`decodebytes`.
241-
242-
.. deprecated:: 3.1
243-
244238

245239
.. function:: encode(input, output)
246240

@@ -261,12 +255,6 @@ The legacy interface:
261255

262256
.. versionadded:: 3.1
263257

264-
.. function:: encodestring(s)
265-
266-
Deprecated alias of :func:`encodebytes`.
267-
268-
.. deprecated:: 3.1
269-
270258

271259
An example usage of the module:
272260

‎Doc/whatsnew/3.9.rst

Copy file name to clipboardExpand all lines: Doc/whatsnew/3.9.rst
+5Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -411,6 +411,11 @@ Removed
411411
of :pep:`442`. Patch by Joannah Nanjekye.
412412
(Contributed by Joannah Nanjekye in :issue:`15088`)
413413

414+
* ``base64.encodestring()`` and ``base64.decodestring()``, aliases deprecated
415+
since Python 3.1, have been removed: use :func:`base64.encodebytes` and
416+
:func:`base64.decodebytes` instead.
417+
(Contributed by Victor Stinner in :issue:`39351`.)
418+
414419

415420
Porting to Python 3.9
416421
=====================

‎Lib/base64.py

Copy file name to clipboardExpand all lines: Lib/base64.py
-16Lines changed: 0 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -531,28 +531,12 @@ def encodebytes(s):
531531
pieces.append(binascii.b2a_base64(chunk))
532532
return b"".join(pieces)
533533

534-
def encodestring(s):
535-
"""Legacy alias of encodebytes()."""
536-
import warnings
537-
warnings.warn("encodestring() is a deprecated alias since 3.1, "
538-
"use encodebytes()",
539-
DeprecationWarning, 2)
540-
return encodebytes(s)
541-
542534

543535
def decodebytes(s):
544536
"""Decode a bytestring of base-64 data into a bytes object."""
545537
_input_type_check(s)
546538
return binascii.a2b_base64(s)
547539

548-
def decodestring(s):
549-
"""Legacy alias of decodebytes()."""
550-
import warnings
551-
warnings.warn("decodestring() is a deprecated alias since Python 3.1, "
552-
"use decodebytes()",
553-
DeprecationWarning, 2)
554-
return decodebytes(s)
555-
556540

557541
# Usable as a script...
558542
def main():

‎Lib/test/test_base64.py

Copy file name to clipboardExpand all lines: Lib/test/test_base64.py
-8Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,14 +18,6 @@ def check_type_errors(self, f):
1818
int_data = memoryview(b"1234").cast('I')
1919
self.assertRaises(TypeError, f, int_data)
2020

21-
def test_encodestring_warns(self):
22-
with self.assertWarns(DeprecationWarning):
23-
base64.encodestring(b"www.python.org")
24-
25-
def test_decodestring_warns(self):
26-
with self.assertWarns(DeprecationWarning):
27-
base64.decodestring(b"d3d3LnB5dGhvbi5vcmc=\n")
28-
2921
def test_encodebytes(self):
3022
eq = self.assertEqual
3123
eq(base64.encodebytes(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=\n")
+3Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
Remove ``base64.encodestring()`` and ``base64.decodestring()``, aliases
2+
deprecated since Python 3.1: use :func:`base64.encodebytes` and
3+
:func:`base64.decodebytes` instead.

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.