File tree Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Expand file tree Collapse file tree 3 files changed +25
-6
lines changed Original file line number Diff line number Diff 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
270279An example usage of the module:
Original file line number Diff line number Diff line change @@ -542,7 +542,8 @@ def encodebytes(s):
542542def 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):
555556def 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
Original file line number Diff line number Diff 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 " )
You can’t perform that action at this time.
0 commit comments