[docs] [issue25495] binascii documentation incorrect
Martin Panter
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
...
while True:
s = input.read(MAXBINSIZE)
if not s:
break
line = binascii.b2a_base64(s)
output.write(line)
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>
<http://bugs.python.org/issue25495>
_______________________________________
More information about the docs
mailing list