[issue28426] PyUnicode_AsDecodedObject can only return unicode now

Marc-Andre Lemburg report at bugs.python.org
Tue Oct 25 02:53:33 EDT 2016


Marc-Andre Lemburg added the comment:

On 25.10.2016 04:16, Xiang Zhang wrote:
> Marc-Andre, shouldn't the C API of unicode.encode() be PyUnicode_AsEncodedString instead of PyUnicode_AsEncodedUnicode now?

You're right. I got confused with all the slight variations.

> BTW Serhiy, how about PyUnicode_AsEncodedObject? Not see it in your deprecate list.

Let's see what we have:

PyUnicode_AsEncodedString(): encode to bytes (unicode.encode())
PyUnicode_AsEncodedUnicode(): encode to unicode (for e.g. rot13)
PyUnicode_AsEncodedObject(): encode to whatever the codec returns

codecs.encode() can be used for the last two.

----------

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue28426>
_______________________________________


More information about the Python-bugs-list mailing list