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

Add Python version since deprecation in base64 methods. #33

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 2, 2017
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
Add Python version since deprecation in base64 methods.
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.
  • Loading branch information
Carreau committed Feb 16, 2017
commit 1e409fb1ca968b092f128463a85a0cda670f1cff
17 changes: 13 additions & 4 deletions 17 Doc/library/base64.rst
Original file line number Diff line number Diff line change
Expand Up @@ -237,14 +237,18 @@ The legacy interface:


.. function:: decodebytes(s)
decodestring(s)

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

.. versionadded:: 3.1

.. function:: decodestring(s)

Deprecated alias of :func:`decodebytes`

.. deprecated:: 3.1


.. function:: encode(input, output)

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


.. function:: encodebytes(s)
encodestring(s)

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

``encodestring`` is a deprecated alias.
.. versionadded:: 3.1

.. function:: encodestring(s)

Deprecated alias of :func:`encodebytes`

.. deprecated:: 3.1


An example usage of the module:
Expand Down
6 changes: 4 additions & 2 deletions 6 Lib/base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -541,7 +541,8 @@ def encodebytes(s):
def encodestring(s):
"""Legacy alias of encodebytes()."""
import warnings
warnings.warn("encodestring() is a deprecated alias, use encodebytes()",
warnings.warn("encodestring() is a deprecated alias since 3.1, "
"use encodebytes()",
DeprecationWarning, 2)
return encodebytes(s)

Expand All @@ -554,7 +555,8 @@ def decodebytes(s):
def decodestring(s):
"""Legacy alias of decodebytes()."""
import warnings
warnings.warn("decodestring() is a deprecated alias, use decodebytes()",
warnings.warn("decodestring() is a deprecated alias since Python 3.1, "
"use decodebytes()",
DeprecationWarning, 2)
return decodebytes(s)

Expand Down
8 changes: 8 additions & 0 deletions 8 Lib/test/test_base64.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,14 @@ def check_type_errors(self, f):
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")
Expand Down
Morty Proxy This is a proxified and sanitized view of the page, visit original site.