[Python-Dev] Why can't I encode/decode base64 without importing a module?
ncoghlan at gmail.com
Thu Apr 25 09:49:33 CEST 2013
On Thu, Apr 25, 2013 at 4:57 PM, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> Lennart Regebro writes:
> > Base64 is an encoding that transforms between 8-bit streams. Let it be
> > that. Don't try to shoehorn it into a completely different kind of
> > encoding.
> By "completely different kind of encoding" do you mean "codec"?
> I think that would be an unfortunate result. These operations on
> streams are theoretically nicely composable. It would be nice if
> practice reflected that by having a uniform API for all of these
> operations (charset translation, encoded text to internal, content
> transfer encoding, compression ...). I think it would be useful, too,
> though I can't prove that.
> Anyway, this discussion belongs on python-ideas at this point. Or
> would, if I had an idea about implementation. I'll take it there when
> I do have something to say about implementation.
Bringing the mailing list thread up to date with the state of the
relevant tracker issues:
I created http://bugs.python.org/issue17827 to cover adding the
missing documentation for "codecs.encode" and "codecs.decode" as the
officially supported solutions for easy use of the codec
infrastructure *without* the additional text model specific input and
output type restrictions imposed by the str.encode, bytes.decode and
I created http://bugs.python.org/issue17828 to cover emitting more
meaningful exceptions when a codec throws TypeError or ValueError, as
well as when the additional type checking fails for str.encode,
bytes.decode and bytearray.decode.
I created http://bugs.python.org/issue17839 to cover the fact that
part of the problem here is that the base64 module currently only
accepts bytes and bytearray as inputs, rather than anything that
supports the PEP 3118 buffer interface.
http://bugs.python.org/issue7475 (linked earlier in the thread) is now
strictly about restoring the shorthand aliases for "base64_codec",
"bz2_codec" et al that were removed in
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev