[Python-bugs-list] [ python-Bugs-216388 ] cStringIO rejects Unicode strings

noreply@sourceforge.net noreply@sourceforge.net
Tue, 23 Apr 2002 05:55:32 -0700


Bugs item #216388, was opened at 2000-10-08 20:42
You can respond by visiting: 
http://sourceforge.net/tracker/?func=detail&atid=105470&aid=216388&group_id=5470

Category: Unicode
Group: Feature Request
>Status: Closed
>Resolution: Wont Fix
Priority: 5
Submitted By: Paul Prescod (prescod)
Assigned to: Fred L. Drake, Jr. (fdrake)
Summary: cStringIO rejects Unicode strings

Initial Comment:
>>> import cStringIO
>>> s=cStringIO.StringIO(u"abcdefgh")
Traceback (innermost last):
  File "<pyshell#8>", line 1, in ?
    s=cStringIO.StringIO(u"abcdefgh")
TypeError: expected string, unicode found


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

>Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-23 08:55

Message:
Logged In: YES 
user_id=6380

Let's please move this discussion to a new bug report on the
new problem. I've opened one, 547537, and summarized the
issue there. I've assigned ot to MAL.

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

Comment By: Anthony Baxter (anthonybaxter)
Date: 2002-04-23 03:10

Message:
Logged In: YES 
user_id=29957

well, StringIO does the correct thing (returns back
a unicode string), fwiw. 

the offending checkin for cStringIO was 2.30. The commit
log is:

  date: 2001/09/24 17:34:52;  author: lemburg;  state: Exp;
 lines: +5 -9
  StringIO patch #462596: let's [c]StringIO accept read
buffers on
  input to .write() too.

The referenced patch is actually doing a bit more than
'write':
  This patch allows using arbitrary read-buffer
  compatible objects as basis for StringIO and cStringIO
  objects.

I'm not sure what on the appropriate way to fix this

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2002-04-18 08:53

Message:
Logged In: YES 
user_id=6380

Hm, that's bad. An error on write(u"...") is much preferred
over wreiting garbage. :-(

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

Comment By: Anthony Baxter (anthonybaxter)
Date: 2002-04-18 02:38

Message:
Logged In: YES 
user_id=29957

Hm. This no longer produces the above error. However, it
now produces:
>>> import cStringIO 
>>> s=cStringIO.StringIO(u"abcdefgh") 
>>> s.getvalue()
'a\x00b\x00c\x00d\x00e\x00f\x00g\x00h\x00'

Should it produce a unicode string back? 
(thought I'd go through some of the older sf bugs)

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

Comment By: Nobody/Anonymous (nobody)
Date: 2002-04-04 06:18

Message:
Logged In: NO 

9;lo;;99999999999999999999999

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

Comment By: Jeremy Hylton (jhylton)
Date: 2002-03-01 17:31

Message:
Logged In: YES 
user_id=31392

Setting back to normal priority for 2.2


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

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-01-16 21:29

Message:
Lowered priority to reflect my previous comments; I don't think I'll have time to do this for Python 2.1.

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

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-01-10 11:07

Message:
Status:  Jim said I can work on it, but the priority isn't very high for him.

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

Comment By: Fred L. Drake, Jr. (fdrake)
Date: 2001-01-07 22:56

Message:
Ok, ok, ok... I've sent a prod to appropriate people.  This *should* be interesting to have done.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2000-12-12 16:00

Message:
Assigned to Fred -- maybe you can prod Jim into looking into this.

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

Comment By: M.-A. Lemburg (lemburg)
Date: 2000-10-09 04:34

Message:
I've marked this as feature request since making the standard
lib Unicode compatible is a post-2.0 project (probably a good
one for 2.1).


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

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