[docs] [issue25495] binascii documentation incorrect
report at bugs.python.org
Fri Oct 30 18:50:38 EDT 2015
Martin Panter added the comment:
I was only referring to the original Python documentation and library. See the base64.encode() implementation for an example which does do this 57-byte pre-chunking. Simplified:
MAXLINESIZE = 76 # Excluding the CRLF
MAXBINSIZE = (MAXLINESIZE//4)*3 # 57
s = input.read(MAXBINSIZE)
if not s:
line = binascii.b2a_base64(s)
Here’s my attempt to rewrite the doc (3.6 version):
Convert binary data to the base 64 encoding defined in :rfc:`4648`. The return value includes a trailing newline ``b"\n"`` if *newline* is true.
To be MIME-compliant, base 64 output should be broken into lines at most 76 characters long. One way to do this is to call this function with 57-byte chunks and ``newline=True``. Also, the original PEM context-transfer encoding limited the line length to 64 characters.
But if PEM is long gone as you say, perhaps we don’t need that last sentence?
Python tracker <report at bugs.python.org>
More information about the docs