[Python-Dev] Re: [XML-SIG] printing Unicode xml to StringIO (original) (raw)

Martin v. Loewis martin@v.loewis.de
Fri, 28 Dec 2001 12:25:46 +0100


Both of these implementation are targetted at providing a file IO like interface to in-memory "files". Since Python file object don't magically support Unicode, I wonder where the idea came from that StringIO/cStringIO should.

The exact source of this idea is unknown. However, there are many early references to it:

So I would not blame the users for adopting far-off ideas, when the Python core itself suggests that these ideas are Pythonic.

That patch I applied to StringIO/cStringIO for 2.2 was aimed at making these two more compatible to the standard Python file object. The latter uses the "s#" parser marker for .write() and thus can also accept memory buffers. This was previously not possible with either of the two StringIO implementation (StringIO.py failed when trying to join different buffer compatible objects, cStringIO only accepted real string objects).

There is nothing wrong with that. The patch should just have special-cased Unicode objects (and that bug can still be corrected).

Regards, Martin