[issue7785] FileIO.write() accepts Unicode strings

David Beazley report at bugs.python.org
Tue Jan 26 14:10:13 CET 2010


New submission from David Beazley <dave at dabeaz.com>:

Is io.FileIO.write() supposed to accept and implicitly encode Unicode strings as illustrated by this simple example?

>>> f = open("/dev/null","wb",buffering=0)
>>> f.write("Hello World\n")
12
>>> 

Moreover, is the behavior of BufferedWriter objects supposed to be different as illustrated by this example:

>>> f = open("/dev/null","wb")
>>> f.write("Hello World\n")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
TypeError: write() argument 1 must be bytes or buffer, not str
>>>

----------
components: IO
messages: 98333
nosy: dabeaz
severity: normal
status: open
title: FileIO.write() accepts Unicode strings
type: behavior
versions: Python 3.1

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7785>
_______________________________________


More information about the Python-bugs-list mailing list