Any reason why cStringIO in 2.5 behaves different from 2.4?

Stefan Scholl stesch at no-spoon.de
Thu Jul 26 10:28:00 CEST 2007


After an hour searching for a potential bug in XML parsing
(PyXML), after updating from 2.4 to 2.5, I found this one:


$ python2.5
Python 2.5 (release25-maint, Dec  9 2006, 14:35:53)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-20)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import StringIO
>>> x = StringIO.StringIO(u"m\xf6p")
>>> import cStringIO
>>> x = cStringIO.StringIO(u"m\xf6p")
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
UnicodeEncodeError: 'ascii' codec can't encode character u'\xf6' in position 1: ordinal not in range(128)
>>>
$ python
Python 2.4.4 (#2, Apr  5 2007, 20:11:18)
[GCC 4.1.2 20061115 (prerelease) (Debian 4.1.1-21)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import StringIO
>>> x = StringIO.StringIO(u"m\xf6p")
>>> import cStringIO
>>> x = cStringIO.StringIO(u"m\xf6p")
>>>


OK, that's why my code was fine with Python 2.4 and breaks with
2.5.

{sigh}


-- 
Web (en): http://www.no-spoon.de/ -*- Web (de): http://www.frell.de/



More information about the Python-list mailing list