summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorVictor Stinner <vstinner@python.org>2020-01-16 10:24:16 +0100
committerGitHub <noreply@github.com>2020-01-16 10:24:16 +0100
commit210c19e3c5b86535a73487fa737752de8eb1d866 (patch)
tree81473e9158c48984c4e71827275143ed3c8c9504
parentfad8b5674c66d9e00bb788e30adddb0c256c787b (diff)
downloadcpython-git-210c19e3c5b86535a73487fa737752de8eb1d866.tar.gz
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.
-rw-r--r--Doc/library/base64.rst12
-rw-r--r--Doc/whatsnew/3.9.rst5
-rwxr-xr-xLib/base64.py16
-rw-r--r--Lib/test/test_base64.py8
-rw-r--r--Misc/NEWS.d/next/Library/2020-01-16-09-27-28.bpo-39351.a-FQdv.rst3
5 files changed, 8 insertions, 36 deletions
diff --git a/Doc/library/base64.rst b/Doc/library/base64.rst
index ad9f5f58be..1ff22a00d6 100644
--- a/Doc/library/base64.rst
+++ b/Doc/library/base64.rst
@@ -235,12 +235,6 @@ The legacy interface:
.. versionadded:: 3.1
-.. function:: decodestring(s)
-
- Deprecated alias of :func:`decodebytes`.
-
- .. deprecated:: 3.1
-
.. function:: encode(input, output)
@@ -261,12 +255,6 @@ The legacy interface:
.. versionadded:: 3.1
-.. function:: encodestring(s)
-
- Deprecated alias of :func:`encodebytes`.
-
- .. deprecated:: 3.1
-
An example usage of the module:
diff --git a/Doc/whatsnew/3.9.rst b/Doc/whatsnew/3.9.rst
index 451902ab1d..47e8a37e56 100644
--- a/Doc/whatsnew/3.9.rst
+++ b/Doc/whatsnew/3.9.rst
@@ -411,6 +411,11 @@ Removed
of :pep:`442`. Patch by Joannah Nanjekye.
(Contributed by Joannah Nanjekye in :issue:`15088`)
+* ``base64.encodestring()`` and ``base64.decodestring()``, aliases deprecated
+ since Python 3.1, have been removed: use :func:`base64.encodebytes` and
+ :func:`base64.decodebytes` instead.
+ (Contributed by Victor Stinner in :issue:`39351`.)
+
Porting to Python 3.9
=====================
diff --git a/Lib/base64.py b/Lib/base64.py
index 2e70223dfe..a28109f8a7 100755
--- a/Lib/base64.py
+++ b/Lib/base64.py
@@ -531,28 +531,12 @@ def encodebytes(s):
pieces.append(binascii.b2a_base64(chunk))
return b"".join(pieces)
-def encodestring(s):
- """Legacy alias of encodebytes()."""
- import warnings
- warnings.warn("encodestring() is a deprecated alias since 3.1, "
- "use encodebytes()",
- DeprecationWarning, 2)
- return encodebytes(s)
-
def decodebytes(s):
"""Decode a bytestring of base-64 data into a bytes object."""
_input_type_check(s)
return binascii.a2b_base64(s)
-def decodestring(s):
- """Legacy alias of decodebytes()."""
- import warnings
- warnings.warn("decodestring() is a deprecated alias since Python 3.1, "
- "use decodebytes()",
- DeprecationWarning, 2)
- return decodebytes(s)
-
# Usable as a script...
def main():
diff --git a/Lib/test/test_base64.py b/Lib/test/test_base64.py
index 7dba6635d4..1dbeac41dc 100644
--- a/Lib/test/test_base64.py
+++ b/Lib/test/test_base64.py
@@ -18,14 +18,6 @@ class LegacyBase64TestCase(unittest.TestCase):
int_data = memoryview(b"1234").cast('I')
self.assertRaises(TypeError, f, int_data)
- def test_encodestring_warns(self):
- with self.assertWarns(DeprecationWarning):
- base64.encodestring(b"www.python.org")
-
- def test_decodestring_warns(self):
- with self.assertWarns(DeprecationWarning):
- base64.decodestring(b"d3d3LnB5dGhvbi5vcmc=\n")
-
def test_encodebytes(self):
eq = self.assertEqual
eq(base64.encodebytes(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=\n")
diff --git a/Misc/NEWS.d/next/Library/2020-01-16-09-27-28.bpo-39351.a-FQdv.rst b/Misc/NEWS.d/next/Library/2020-01-16-09-27-28.bpo-39351.a-FQdv.rst
new file mode 100644
index 0000000000..b89bec97bf
--- /dev/null
+++ b/Misc/NEWS.d/next/Library/2020-01-16-09-27-28.bpo-39351.a-FQdv.rst
@@ -0,0 +1,3 @@
+Remove ``base64.encodestring()`` and ``base64.decodestring()``, aliases
+deprecated since Python 3.1: use :func:`base64.encodebytes` and
+:func:`base64.decodebytes` instead.