[issue34736] Confusing base64.b64decode output

Tal Einat report at bugs.python.org
Sat Sep 22 16:08:14 EDT 2018


Tal Einat <taleinat at gmail.com> added the comment:

> I think what I _really_ want as a user is for b64decode to reject strings containing...

Do you mean you'd like to have this behavior by default?  One can already use validate=True to have invalid characters cause an exception.  I too find it surprising the False is the default, but changing this would be backwards incompatible.

> I find the "1 more than a multiple of 4" wording a bit clunky, and potentially misleading.

I chose that to avoid mentioning "modulu" or "remainder".  I find it straightforward and clear, though admittedly a bit long and clumsy.  I don't believe it is inherently misleading, though.

I like your idea of including the number of base64 characters in the error message.  I find the phrase "base64 characters" ambiguous, though.  I suggest: "Invalid base64-encoded string: number of data characters (13) cannot be 1 more than a multiple of 4"

----------

_______________________________________
Python tracker <report at bugs.python.org>
<https://bugs.python.org/issue34736>
_______________________________________


More information about the Python-bugs-list mailing list