[Python-Dev] Restoring the aliases for the non-Unicode codecs
Nick Coghlan
ncoghlan at gmail.com
Wed Nov 13 17:30:38 CET 2013
On 14 November 2013 01:43, Stephen J. Turnbull <stephen at xemacs.org> wrote:
> Nick Coghlan writes:
>
> > The long gory history in http://bugs.python.org/issue7475 took a
> > different turn earlier this year when I noticed
> > (http://bugs.python.org/issue7475#msg187698) that the codecs module
> > already *had* type neutral helper functions in the form of
> > codecs.encode and codecs.decode, and has had them since Python 2.4.
> > These were covered in the test suite, but not in the documentation.
>
> As long as the agreement on _methods_ (documented in
> http://bugs.python.org/issue7475#msg96240) isn't changed, I'm +1 on
> this.
Yeah, those have actually been updated to point to the type neutral functions:
>>> "bad output".encode("rot_13")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'rot_13' encoder returned 'str' instead of 'bytes'; use
codecs.encode() to encode to arbitrary types
>>> b"bad output".decode("quopri_codec")
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: 'quopri_codec' decoder returned 'bytes' instead of 'str';
use codecs.decode() to decode to arbitrary types
Cheers,
Nick.
--
Nick Coghlan | ncoghlan at gmail.com | Brisbane, Australia
More information about the Python-Dev
mailing list