Surprising difference between StringIO.StringIO and io.StringIO

Skip Montanaro skip at pobox.com
Thu May 30 19:43:08 EDT 2013


>
> I would expect io.StringIO to be a match for the io.* stuff in Python
> 3. So it should care whether it is a binary stream or a text stream.
> Whereas StringIO.StringIO is your good old Python 2 StringIO, which expects
> strs.
>
> On that basis, io.StringIO is a text stream, expecting Unicode
> objects for transcription. 'str' is, in that context, probably
> considered as 'bytes' in Python 3.
>

Thanks.  This example was based on a function in Matplotlib. It appears the
author switched from StringIO.StringIO to io.StringIO between 1.1 and 1.2.

Skip
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-list/attachments/20130530/549b3011/attachment.html>


More information about the Python-list mailing list