This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: FileIO.write() accepts Unicode strings
Type: behavior Stage: test needed
Components: IO Versions: Python 3.1
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: benjamin.peterson, dabeaz, ezio.melotti, pitrou
Priority: normal Keywords:

Created on 2010-01-26 13:10 by dabeaz, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (2)
msg98333 - (view) Author: David Beazley (dabeaz) Date: 2010-01-26 13:10
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
>>>
msg98398 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-01-27 01:47
Oops. Fixed in r77781.
History
Date User Action Args
2022-04-11 14:56:56adminsetgithub: 52033
2010-01-27 01:47:28benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg98398

resolution: fixed
2010-01-26 14:43:15ezio.melottisetpriority: normal
nosy: + ezio.melotti

stage: test needed
2010-01-26 13:53:16r.david.murraysetnosy: + pitrou
2010-01-26 13:10:11dabeazcreate