XML: minidom toxml() does not work for non English files! :-(

Steve Holden sholden at holdenweb.com
Mon May 6 17:32:17 EDT 2002


Well, at the start of the __init__ we see:

        self.buf = str(buf)
        self.len = len(buf)

This is clearly wrong, and the second line should be

        self.len = len(buf)

This is why you are only getting three characters back!

I've reported this with the suggested patch as bug # 553031, but you can
make the same change in your own version of the library if you want. After
this fix I get:

Python 2.2 (#1, Dec 31 2001, 15:21:18)
[GCC 2.95.3-5 (cygwin special)] on cygwin
Type "help", "copyright", "credits" or "license" for more information.
>>> import StringIO
>>> StringIO.StringIO([1,2,3]).read()
'[1, 2, 3]'
>>>

regards
 Steve
--

Steve Holden: http://www.holdenweb.com/ ; Python Web Programming:
http://pydish.holdenweb.com/pwp/


"Brian Quinlan" <brian at sweetapp.com> wrote in message
news:mailman.1020716352.19549.python-list at python.org...
> I have no idea what the problem is, but the coercion to string strikes
> me as sloppy.
>
> Does anyone actually believe that the following (from PythonLabs Python
> 2.2) is reasonable?
>
> >>> StringIO.StringIO([1,2,3]).read()
> '[1,'
>
> Also,
>
> - if type(buf) is not types.UnicodeType
> + if not isinstance(buf, types.UnicodeType)
>
> Cheers,
> Brian
>
>
>






More information about the Python-list mailing list