New submission from R. David Murray <rdmur...@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 <rep...@bugs.python.org>
<http://bugs.python.org/issue6304>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to