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

Martijn Faassen faassen@vet.uu.nl
Thu, 18 Jul 2002 20:09:25 +0200


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.

Regards,

Martijn