This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author r.david.murray
Recipients gregory.p.smith, r.david.murray
Date 2018-01-04.00:52:25
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1515027145.44.0.467229070634.issue32491@psf.upfronthosting.co.za>
In-reply-to
Content
This reduces to the following:

>>> from binascii import a2b_base64 as f
>>> f(b'MTIzND\nU2Nzg5\n')
b'123456789'
>>> f(b'MTIzND\n')
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
binascii.Error: Incorrect padding

That is, decode does its decoding line by line, whereas decodebytes passes the entire object to a2b_base64 as a single entity.  Apparently a2b_base64 looks at the padding for the entirety of what it is given, which I believe is in accordance with the RFC.  This means that decode is fundamentally broken per the RFC, and there is no obvious way to fix it without adding an incremental decoder to binascii.  And an incremental decoder probably belongs in codecs (assuming we ever resolved the transcode interface issue, I can't actually remember...).

Note that it will work as long as an "integral" number of base64 encoding units are in each line.
History
Date User Action Args
2018-01-04 00:52:25r.david.murraysetrecipients: + r.david.murray, gregory.p.smith
2018-01-04 00:52:25r.david.murraysetmessageid: <1515027145.44.0.467229070634.issue32491@psf.upfronthosting.co.za>
2018-01-04 00:52:25r.david.murraylinkissue32491 messages
2018-01-04 00:52:25r.david.murraycreate