Issue 11716: mixing calls to io.TextIOWrapper.write and io.BufferedWriter.write produces undefined results (original) (raw)

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