[Zope3-checkins] CVS: Zope3/lib/python/Zope/Server/VFS/tests - PosixFilesystemTests.py:1.3 WriteFilesystemTests.py:1.4

Guido van Rossum guido@python.org
Thu, 18 Jul 2002 14:48:46 -0400


> Jeremy Hylton wrote:
> > It sounds like someone ought to fix cStringIO.  (And I don't mean me!)
> > It also sounds like that's a project.
> > 
> > In the meantime, when is it safe to use cStringIO in Zope3?  It's used
> > in 40 files, including the changes I just made inside Zope/Server.
> 
> It's safe if you only work with 8 bits strings and never with unicode
> strings directly. I imagine networking code is fine; writing to
> text files (or binary) should also be fine.
> 
> Of course it's not safe if you expect there can be any unicode coming into
> cStringIO directly without any conversion to (most likely, but this is
> a thorny issue) UTF-8. But I imagine in fact that a positive side effect
> from this limitation in cStringIO is actually that we would detect such
> errors as cStringIO would bail out with an encoding error as soon as it
> gets some unicode data that contains non-ascii range characters. 
> 
> At the same time it's non-trivial to track down the 'leaking' unicode
> string; a good debugging tool could be to set the default encoding in
> site.py to undefined, but that breaks all sorts of other code...
> 
> I imagine adding unit tests for this kind of thing would be useful.

Didn't Jim make a papal edict that all (text) strings in Zope3 have to
be Unicode strings?  That would mean that eventually (almost)
everything will be Unicode.

--Guido van Rossum (home page: http://www.python.org/~guido/)