File tree 3 files changed +25
-6
lines changed
3 files changed +25
-6
lines changed Original file line number Diff line number Diff line change @@ -237,14 +237,18 @@ The legacy interface:
237
237
238
238
239
239
.. function :: decodebytes(s)
240
- decodestring(s)
241
240
242
241
Decode the :term: `bytes-like object ` *s *, which must contain one or more
243
242
lines of base64 encoded data, and return the decoded :class: `bytes `.
244
- ``decodestring `` is a deprecated alias.
245
243
246
244
.. versionadded :: 3.1
247
245
246
+ .. function :: decodestring(s)
247
+
248
+ Deprecated alias of :func: `decodebytes `
249
+
250
+ .. deprecated :: 3.1
251
+
248
252
249
253
.. function :: encode(input, output)
250
254
@@ -257,14 +261,19 @@ The legacy interface:
257
261
258
262
259
263
.. function :: encodebytes(s)
260
- encodestring(s)
261
264
262
265
Encode the :term: `bytes-like object ` *s *, which can contain arbitrary binary
263
266
data, and return :class: `bytes ` containing the base64-encoded data, with newlines
264
267
(``b'\n' ``) inserted after every 76 bytes of output, and ensuring that
265
268
there is a trailing newline, as per :rfc: `2045 ` (MIME).
266
269
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
268
277
269
278
270
279
An example usage of the module:
Original file line number Diff line number Diff line change @@ -541,7 +541,8 @@ def encodebytes(s):
541
541
def encodestring (s ):
542
542
"""Legacy alias of encodebytes()."""
543
543
import warnings
544
- warnings .warn ("encodestring() is a deprecated alias, use encodebytes()" ,
544
+ warnings .warn ("encodestring() is a deprecated alias since 3.1, "
545
+ "use encodebytes()" ,
545
546
DeprecationWarning , 2 )
546
547
return encodebytes (s )
547
548
@@ -554,7 +555,8 @@ def decodebytes(s):
554
555
def decodestring (s ):
555
556
"""Legacy alias of decodebytes()."""
556
557
import warnings
557
- warnings .warn ("decodestring() is a deprecated alias, use decodebytes()" ,
558
+ warnings .warn ("decodestring() is a deprecated alias since Python 3.1, "
559
+ "use decodebytes()" ,
558
560
DeprecationWarning , 2 )
559
561
return decodebytes (s )
560
562
Original file line number Diff line number Diff line change @@ -18,6 +18,14 @@ def check_type_errors(self, f):
18
18
int_data = memoryview (b"1234" ).cast ('I' )
19
19
self .assertRaises (TypeError , f , int_data )
20
20
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
+
21
29
def test_encodebytes (self ):
22
30
eq = self .assertEqual
23
31
eq (base64 .encodebytes (b"www.python.org" ), b"d3d3LnB5dGhvbi5vcmc=\n " )
You can’t perform that action at this time.
0 commit comments