In the official documentation, the signature for str()
passing a bytes
object is:
class
str
( object=b’’ , encoding=‘utf-8’ , errors=‘strict’ )
But the documentation says:
If at least one of encoding or errors is given, […] then
str(bytes, encoding, errors)
is equivalent tobytes.decode(encoding, errors)
. […]Passing a
bytes
object tostr()
without the encoding or errors arguments falls under the first case of returning the informal string representation
Indeed I tested it in REPL and the docs are correct. But in this case, I suppose the correct signature of the class is:
class
str
( object=b’’ , encoding=None , errors=None )
classstr
( object=b’’ [, encoding [, errors ] ] )
as help(str)
reports.