Bugs item #1678411, was opened at 2007-03-11 19:07 Message generated for change (Comment added) made by loewis 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. ---------------------------------------------------------------------- >Comment By: Martin v. Löwis (loewis) Date: 2007-03-11 19:31 Message: Logged In: YES user_id=21627 Originator: NO It's intentional that they behave differently. StringIO supports Unicode strings, cStringIO doesn't. This means that you can build up a large Unicode string with StringIO, but not with cStringIO. What should happen when you mix them is debatable. ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=105470&aid=1678411&group_id=5470 _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com