Message314453
| Author |
serhiy.storchaka |
| Recipients |
docs@python, ezio.melotti, lemburg, martin.panter, serhiy.storchaka, vstinner |
| Date |
2018年03月26日.13:49:48 |
| SpamBayes Score |
-1.0 |
| Marked as misclassified |
Yes |
| Message-id |
<1522072188.34.0.467229070634.issue24024@psf.upfronthosting.co.za> |
| In-reply-to |
| Content |
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
"b'abc'"
>>> str(b'abc', encoding="utf-8", errors="strict")
'abc' |
|