[Python-Dev] Printing and __unicode__

Martin v. Loewis martin@v.loewis.de
13 Nov 2002 22:11:46 +0100

"M.-A. Lemburg" <mal@lemburg.com> writes:

> The fact that StringIO works with Unicode (and then only in the
> case where you *only* pass Unicode to it) is more an implementation
> detail than a true feature. 

It's a true feature. You explicitly fixed that feature in

revision 1.20
date: 2002/01/06 17:15:05;  author: lemburg;  state: Exp;  lines: +8 -5
Restore Python 2.1 StringIO.py behaviour: support concatenating
Unicode string snippets to larger Unicode strings.

This fix should also go into Python 2.2.1.

after you broke it in

revision 1.19
date: 2001/09/24 17:34:52;  author: lemburg;  state: Exp;  lines: +4 -1
branches:  1.19.12;
StringIO patch #462596: let's [c]StringIO accept read buffers on
input to .write() too.

> cStringIO doesn't have this implementation detail, so porting from
> StringIO to the much faster cStringIO doesn't work at all for
> Unicode.

Correct. That still doesn't make it an implementation detail.

> I think that StringIO and cStringIO should be regarded as
> binary streams without any encoding knowledge. It is easy
> enough to wrap these into Unicode aware streams using the
> codecs.StreamReaderWriter class as is done in codecs.open().

Then why did you fix that behaviour when you broke it?