[docs] [issue24024] str.__doc__ needs an update

Serhiy Storchaka report at bugs.python.org
Mon Mar 26 09:49:48 EDT 2018

Serhiy Storchaka <storchaka+cpython at gmail.com> added the comment:

The current docstring is correct. The signature str(object, encoding="utf-8", errors="strict") is not correct, because str(object) is not the same as str(object, encoding="utf-8", errors="strict").

>>> str([1, 2])
'[1, 2]'
>>> str([1, 2], encoding="utf-8", errors="strict")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: decoding to str: need a bytes-like object, list found
>>> str(b'abc')
__main__:1: BytesWarning: str() on a bytes instance
>>> str(b'abc', encoding="utf-8", errors="strict")

nosy: +serhiy.storchaka
status: open -> pending

Python tracker <report at bugs.python.org>

More information about the docs mailing list