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: mixing calls to io.TextIOWrapper.write and io.BufferedWriter.write produces undefined results
Type: behavior Stage:
Components: Library (Lib) Versions: Python 3.1, Python 3.2, Python 2.7
process
Status: closed Resolution: not a bug
Dependencies: Superseder:
Assigned To: Nosy List: Sean.Sherrard
Priority: normal Keywords:

Created on 2011-03-29 23:03 by Sean.Sherrard, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (2)
msg132553 - (view) Author: Sean Sherrard (Sean.Sherrard) Date: 2011-03-29 23:03
Maybe this is by design, but it certainly took me by surprise.

Steps to reproduce:
Python 3.2 (r32:88445, Feb 20 2011, 21:29:02) [MSC v.1500 32 bit (Intel)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> import io
>>> raw = io.BytesIO()
>>> buf = io.BufferedWriter(raw)
>>> txt = io.TextIOWrapper(buf)
>>> txt.write('one.')
4
>>> txt.buffer.write(b'two.')
4
>>> txt.flush()
>>> raw.getvalue()
b'two.one.'

Same results in 2.7
msg132557 - (view) Author: Sean Sherrard (Sean.Sherrard) Date: 2011-03-30 00:00
Never mind, I didn't realize that TextIOWrapper was doing its own buffering. The behaviour makes sense to me now after reading textio.c
History
Date User Action Args
2022-04-11 14:57:15adminsetgithub: 55925
2011-03-30 00:00:16Sean.Sherrardsetstatus: open -> closed
resolution: not a bug
messages: + msg132557
2011-03-29 23:03:17Sean.Sherrardcreate