[ python-Bugs-1678411 ] StringIO / cStringIO inconsistency with unicode

SourceForge.net noreply at sourceforge.net
Sun Mar 11 19:07:01 CET 2007


Bugs item #1678411, was opened at 2007-03-11 18:07
Message generated for change (Tracker Item Submitted) made by Item Submitter
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1678411&group_id=5470

Please note that this message will contain a full copy of the comment thread,
including the initial issue submission, for this request,
not just the latest update.
Category: Python Library
Group: None
Status: Open
Resolution: None
Priority: 5
Private: No
Submitted By: Armin Rigo (arigo)
Assigned to: Nobody/Anonymous (nobody)
Summary: StringIO / cStringIO inconsistency with unicode

Initial Comment:
When trying to write unicode strings into a
StringIO.StringIO() or a cStringIO.StringIO()
file, different things occur.  (This causes
a failing test in the "mako" project if
cStringIO is not available.)  Compare the
following with StringIO or with cStringIO:

    f = StringIO()
    f.write("\xC0")
    f.write(u"hello")
    print f.getvalue()

With cStringIO, unicode strings are
immediately encoded as ascii and the
getvalue() returns '\xC0hello'.  With
StringIO, on the other hand, the
getvalue() crashes in a ''.join()
trying to convert 'xC0' to unicode.
Normal file() objects follow the same
behavior as cStringIO, so my guess is
that StringIO.py is wrong here.

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1678411&group_id=5470


More information about the Python-bugs-list mailing list