The docstring is left not fixed.
str(object='') -> str
str(bytes_or_buffer[, encoding[, errors]]) -> str
I noticed this too; the doc and docstring should be made to agree with
each other and the code.
While exploring the actual behavior, I discovered that while the
presence of encoding triggers decoding of bytes, it is not needed and
hence not checked for null bytes. Hence an invalid encoding is OK in
this edge case.
>>> b''.decode('0')
''
>>> str(b'','0')
''
>>> str(b'')
"b''"
Should this be at least tested if not documented? (So that other
implementations know to check the bytes value before the encoding value?)
--
Terry Jan Reedy
_______________________________________________
Python-Dev mailing list -- python-dev@python.org
To unsubscribe send an email to python-dev-le...@python.org
https://mail.python.org/mailman3/lists/python-dev.python.org/
Message archived at
https://mail.python.org/archives/list/python-dev@python.org/message/SGM6JGK3DEAEV2QMU6T6BLB656YRTEAQ/
Code of Conduct: http://python.org/psf/codeofconduct/