[Python-checkins] python/dist/src/Modules cStringIO.c,2.34,2.35

gvanrossum@sourceforge.net gvanrossum@sourceforge.net
Mon, 29 Apr 2002 06:54:50 -0700


Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv3702

Modified Files:
	cStringIO.c 
Log Message:
See discussion at SF bug 547537.

Unicode objects are currently taken as binary data by the write()
method.  This is not what Unicode users expect, nor what the
StringIO.py code does.  Until somebody adds a way to specify binary or
text mode for cStringIO objects, change the format string to use "t#"
instead of "s#", so that it will request the "text buffer" version.
This will try the default encoding for Unicode objects.

This is *not* a 2.2 bugfix (since it *is* a semantic change).


Index: cStringIO.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/cStringIO.c,v
retrieving revision 2.34
retrieving revision 2.35
diff -C2 -d -r2.34 -r2.35
*** cStringIO.c	4 Apr 2002 17:52:50 -0000	2.34
--- cStringIO.c	29 Apr 2002 13:54:48 -0000	2.35
***************
*** 377,381 ****
          int l;
  
!         UNLESS (PyArg_ParseTuple(args, "s#:write", &c, &l)) return NULL;
  
          if (O_cwrite((PyObject*)self,c,l) < 0) return NULL;
--- 377,381 ----
          int l;
  
!         UNLESS (PyArg_ParseTuple(args, "t#:write", &c, &l)) return NULL;
  
          if (O_cwrite((PyObject*)self,c,l) < 0) return NULL;