This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: cStringIO rejects Unicode strings
Type: enhancement Stage:
Components: Unicode Versions:
process
Status: closed Resolution: wont fix
Dependencies: Superseder:
Assigned To: fdrake Nosy List: anthonybaxter, fdrake, gvanrossum, jhylton, lemburg, nobody, prescod
Priority: normal Keywords:

Created on 2000-10-09 00:42 by prescod, last changed 2022-04-10 16:02 by admin. This issue is now closed.

Messages (14)
msg1961 - (view) Author: Paul Prescod (prescod) * (Python triager) Date: 2000-10-09 00:42
>>> 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
msg1962 - (view) Author: Marc-Andre Lemburg (lemburg) * (Python committer) Date: 2000-10-09 08:34
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).
msg1963 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2000-12-12 21:00
Assigned to Fred -- maybe you can prod Jim into looking into this.
msg1964 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-01-08 03:56
Ok, ok, ok... I've sent a prod to appropriate people.  This *should* be interesting to have done.
msg1965 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-01-10 16:07
Status:  Jim said I can work on it, but the priority isn't very high for him.
msg1966 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2001-01-17 02:29
Lowered priority to reflect my previous comments; I don't think I'll have time to do this for Python 2.1.
msg1967 - (view) Author: Jeremy Hylton (jhylton) (Python triager) Date: 2002-03-01 22:31
Logged In: YES 
user_id=31392

Setting back to normal priority for 2.2
msg1968 - (view) Author: Nobody/Anonymous (nobody) Date: 2002-04-04 11:18
Logged In: NO 

9;lo;;99999999999999999999999
msg1969 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-04-18 06:38
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)
msg1970 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-04-18 12:53
Logged In: YES 
user_id=6380

Hm, that's bad. An error on write(u"...") is much preferred
over wreiting garbage. :-(
msg1971 - (view) Author: Anthony Baxter (anthonybaxter) (Python triager) Date: 2002-04-23 07:10
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
msg1972 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-04-23 12:55
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.
msg1973 - (view) Author: Fred Drake (fdrake) (Python committer) Date: 2002-06-13 15:48
Logged In: YES 
user_id=3066

SF tracker item 547537 gives me an "invalid artifact ID"
message, at least when using:

    http://www.python.org/sf/547537
msg1974 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2002-06-13 16:02
Logged In: YES 
user_id=6380

It's a feature request. Here's the full URL:

http://sourceforge.net/tracker/?func=detail&aid=547537&group_id=5470&atid=355470

I dunno why the redirector doesn't know about it.
History
Date User Action Args
2022-04-10 16:02:29adminsetgithub: 33313
2000-10-09 00:42:04prescodcreate