Author mgiuca
Recipients ajaksu2, ddvoinikov, georg.brandl, gvanrossum, kawai, mgiuca, pitrou
Date 2009-04-24.03:04:18
SpamBayes Score 9.4367e-08
Marked as misclassified No
Message-id <1240542260.97.0.0260739960698.issue3613@psf.upfronthosting.co.za>
In-reply-to
Content
Now, base64.encodestring and decodestring seem a bit weird because the
Base64 encoded string is also required to be a bytes.

It seems to me that once something is Base64-encoded, it's considered to
be ASCII text, not just some byte string, and therefore it should be a
str, not a bytes. (For example, they end with a '\n'. That's something
which strings do, not bytes).

Hence, base64.encodestring (which should be "encodebytes") should take a
bytes and return a str. base64.decodestring should take a str (required
to be ASCII-only) and return a bytes.

I've attached an alternative patch, encodebytes_new_types.patch (which,
unlike my other patch, doesn't rename decodestring to decodebytes). This
patch:

- Renames encodestring to encodebytes.
- Changes the output of encodebytes to return an ASCII str*, not a bytes.
- Changes the input of decodestring to accept an ASCII str, not a bytes.

* An ASCII str is a Unicode string with only ASCII characters.

This isn't a proper patch (it breaks a lot of other code which I haven't
bothered to fix). I'm just submitting it as an idea, in case this is
something we want to do. Most likely not, due to the breakage. Also we
have the same problem for the non-legacy functions, b64encode and
b64decode, etc, so the problem is more widespread than just these two
functions.
History
Date User Action Args
2009-04-24 03:04:21mgiucasetrecipients: + mgiuca, gvanrossum, georg.brandl, pitrou, ajaksu2, kawai, ddvoinikov
2009-04-24 03:04:20mgiucasetmessageid: <1240542260.97.0.0260739960698.issue3613@psf.upfronthosting.co.za>
2009-04-24 03:04:19mgiucalinkissue3613 messages
2009-04-24 03:04:18mgiucacreate