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 d0620bc

Browse filesBrowse files
authored
Add Python version since deprecation in base64 methods. (#33) (#430)
Allow developers to not have to either test on N Python versions or looked through multiple versions of the docs to know whether they can easily update. (cherry picked from commit c643a96)
1 parent 0ad7b62 commit d0620bc
Copy full SHA for d0620bc

File tree

3 files changed

+25
-6
lines changed
Filter options

3 files changed

+25
-6
lines changed

‎Doc/library/base64.rst

Copy file name to clipboardExpand all lines: Doc/library/base64.rst
+13-4Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -237,14 +237,18 @@ The legacy interface:
237237

238238

239239
.. function:: decodebytes(s)
240-
decodestring(s)
241240

242241
Decode the :term:`bytes-like object` *s*, which must contain one or more
243242
lines of base64 encoded data, and return the decoded :class:`bytes`.
244-
``decodestring`` is a deprecated alias.
245243

246244
.. versionadded:: 3.1
247245

246+
.. function:: decodestring(s)
247+
248+
Deprecated alias of :func:`decodebytes`.
249+
250+
.. deprecated:: 3.1
251+
248252

249253
.. function:: encode(input, output)
250254

@@ -257,14 +261,19 @@ The legacy interface:
257261

258262

259263
.. function:: encodebytes(s)
260-
encodestring(s)
261264

262265
Encode the :term:`bytes-like object` *s*, which can contain arbitrary binary
263266
data, and return :class:`bytes` containing the base64-encoded data, with newlines
264267
(``b'\n'``) inserted after every 76 bytes of output, and ensuring that
265268
there is a trailing newline, as per :rfc:`2045` (MIME).
266269

267-
``encodestring`` is a deprecated alias.
270+
.. versionadded:: 3.1
271+
272+
.. function:: encodestring(s)
273+
274+
Deprecated alias of :func:`encodebytes`.
275+
276+
.. deprecated:: 3.1
268277

269278

270279
An example usage of the module:

‎Lib/base64.py

Copy file name to clipboardExpand all lines: Lib/base64.py
+4-2Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,8 @@ def encodebytes(s):
542542
def encodestring(s):
543543
"""Legacy alias of encodebytes()."""
544544
import warnings
545-
warnings.warn("encodestring() is a deprecated alias, use encodebytes()",
545+
warnings.warn("encodestring() is a deprecated alias since 3.1, "
546+
"use encodebytes()",
546547
DeprecationWarning, 2)
547548
return encodebytes(s)
548549

@@ -555,7 +556,8 @@ def decodebytes(s):
555556
def decodestring(s):
556557
"""Legacy alias of decodebytes()."""
557558
import warnings
558-
warnings.warn("decodestring() is a deprecated alias, use decodebytes()",
559+
warnings.warn("decodestring() is a deprecated alias since Python 3.1, "
560+
"use decodebytes()",
559561
DeprecationWarning, 2)
560562
return decodebytes(s)
561563

‎Lib/test/test_base64.py

Copy file name to clipboardExpand all lines: Lib/test/test_base64.py
+8Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ 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+
2129
def test_encodebytes(self):
2230
eq = self.assertEqual
2331
eq(base64.encodebytes(b"www.python.org"), b"d3d3LnB5dGhvbi5vcmc=\n")

0 commit comments

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