The actual code has accepted Unicode strings (type str) in Python 3 for a long time. In both Python 2 and 3, utf8Bytes can be of a type named str. In Python 2, that's a byte string type, and the bytes must be UTF-8. In Python 3 it is a Unicode string type, and string will be converted to UTF-8 bytes. In Python 3 the argument can also be of type bytes, which is equivalent to passing a str (byte string) in Python 2, so likewise it must be UTF-8 encoded.
The actual code has accepted Unicode strings (type
str
) in Python 3 for a long time. In both Python 2 and 3,utf8Bytes
can be of a type namedstr
. In Python 2, that's a byte string type, and the bytes must be UTF-8. In Python 3 it is a Unicode string type, and string will be converted to UTF-8 bytes. In Python 3 the argument can also be of typebytes
, which is equivalent to passing astr
(byte string) in Python 2, so likewise it must be UTF-8 encoded.