[Python-checkins] CVS: python/dist/src/Lib StringIO.py,1.19,1.20

M.-A. Lemburg lemburg@users.sourceforge.net
Sun, 06 Jan 2002 09:15:07 -0800


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

Modified Files:
	StringIO.py 
Log Message:
Restore Python 2.1 StringIO.py behaviour: support concatenating
Unicode string snippets to larger Unicode strings.

This fix should also go into Python 2.2.1.



Index: StringIO.py
===================================================================
RCS file: /cvsroot/python/python/dist/src/Lib/StringIO.py,v
retrieving revision 1.19
retrieving revision 1.20
diff -C2 -d -r1.19 -r1.20
*** StringIO.py	2001/09/24 17:34:52	1.19
--- StringIO.py	2002/01/06 17:15:05	1.20
***************
*** 29,33 ****
  - There's a simple test set (see end of this file).
  """
! 
  try:
      from errno import EINVAL
--- 29,33 ----
  - There's a simple test set (see end of this file).
  """
! import types
  try:
      from errno import EINVAL
***************
*** 39,44 ****
  class StringIO:
      def __init__(self, buf = ''):
!         # Force self.buf to be a string
!         self.buf = str(buf)
          self.len = len(buf)
          self.buflist = []
--- 39,46 ----
  class StringIO:
      def __init__(self, buf = ''):
!         # Force self.buf to be a string or unicode
!         if type(buf) is not types.UnicodeType:
!             buf = str(buf)
!         self.buf = buf
          self.len = len(buf)
          self.buflist = []
***************
*** 136,141 ****
              raise ValueError, "I/O operation on closed file"
          if not s: return
!         # Force s to be a string
!         s = str(s)
          if self.pos > self.len:
              self.buflist.append('\0'*(self.pos - self.len))
--- 138,144 ----
              raise ValueError, "I/O operation on closed file"
          if not s: return
!         # Force s to be a string or unicode
!         if type(s) is not types.UnicodeType:
!             s = str(s)
          if self.pos > self.len:
              self.buflist.append('\0'*(self.pos - self.len))