On 14 November 2013 01:43, Stephen J. Turnbull <step...@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 | ncogh...@gmail.com | Brisbane, Australia _______________________________________________ Python-Dev mailing list Python-Dev@python.org https://mail.python.org/mailman/listinfo/python-dev Unsubscribe: https://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com