[New-bugs-announce] [issue6304] Confusing error message when passing bytes to print with file pointing to a binary file
R. David Murray
report at bugs.python.org
Thu Jun 18 04:51:45 CEST 2009
New submission from R. David Murray <rdmurray at bitdance.com>:
The documentation for the print function specifies that the input
argument is coerced to string. However, if bytes are passed and the
file= parameter points to a file open for binary write, the error
message produced is:
>>> out = open('temp', 'wb')
>>> print(b'abc', file=out)
Traceback (most recent call last):
File "<stdin>", line 1, in <module>
TypeError: write() argument 1 must be bytes or buffer, not str
which is, to say the least, confusing, since I clearly passed print a
bytes object as argument 1.
----------
components: IO
messages: 89490
nosy: r.david.murray
priority: low
severity: normal
stage: test needed
status: open
title: Confusing error message when passing bytes to print with file pointing to a binary file
type: behavior
versions: Python 3.1, Python 3.2
_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue6304>
_______________________________________
More information about the New-bugs-announce
mailing list