[issue24159] Misleading TypeError when pickling bytes to a file opened as text
Serhiy Storchaka
report at bugs.python.org
Sun Feb 19 14:24:35 EST 2017
Serhiy Storchaka added the comment:
I think it is worth to improve the error message in the write() method of binary files.
>>> sys.stdout.write(b'')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: write() argument must be str, not bytes
>>> sys.stdout.buffer.write('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
>>> sys.stdout.buffer.raw.write('')
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: a bytes-like object is required, not 'str'
But this is large issue. Other file-like objects (GzipFile, ZipExtFile etc) should be updated too.
----------
nosy: +serhiy.storchaka
type: behavior -> enhancement
versions: +Python 3.7 -Python 3.5
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue24159>
_______________________________________
More information about the Python-bugs-list
mailing list