[New-bugs-announce] [issue7785] FileIO.write() accepts Unicode strings

David Beazley report at bugs.python.org
Tue Jan 26 14:10:12 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")

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>

More information about the New-bugs-announce mailing list