[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 19:50:01 +0200


Jeremy Hylton wrote:
> >>>>> "TS" =3D=3D Tres Seaver <tseaver@zope.com> writes:
>=20
>   TS> On Wed, 2002-07-17 at 19:10, Jeremy Hylton wrote:
>   >> =3D=3D=3D
>   >> Zope3/lib/python/Zope/Server/VFS/tests/WriteFilesystemTests.py
>   >> 1.3 =3D> 1.4 =3D=3D=3D
>   >>
>   >> $Id$ """ -from StringIO import StringIO +from cStringIO import
>   >> StringIO
>=20
>   TS> Doesn't this create Unicode-compatibility problems?
>=20
> I have no idea :-).
>=20
> What are the Unicode-compatibility issues with cStringIO?

>>> from cStringIO import StringIO
>>> f =3D StringIO()
>>> f.write(u'foo')
>>> f.write(u'bar')
>>> f.getvalue()
'foobar'

versus

>>> from StringIO import StringIO
>>> f =3D StringIO()
>>> f.write(u'foo')
>>> f.write(u'bar')
>>> f.getvalue()
u'foobar'

i.e. cStringIO tries to make everything into 8 bit strings. Apparently
(I just tested) it tries to get a str() upon input:

>>> from cStringIO import StringIO
>>> f =3D StringIO()
>>> f.write(u'foo=EB')

will get you an ASCII encoding error.

Regards,

Martijn