Message86391
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. |
|
Date |
User |
Action |
Args |
2009-04-24 03:04:21 | mgiuca | set | recipients:
+ mgiuca, gvanrossum, georg.brandl, pitrou, ajaksu2, kawai, ddvoinikov |
2009-04-24 03:04:20 | mgiuca | set | messageid: <1240542260.97.0.0260739960698.issue3613@psf.upfronthosting.co.za> |
2009-04-24 03:04:19 | mgiuca | link | issue3613 messages |
2009-04-24 03:04:18 | mgiuca | create | |
|