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

Michael Hudson mwh@users.sourceforge.net
2002年1月28日 07:00:30 -0800


Update of /cvsroot/python/python/dist/src/Lib
In directory usw-pr-cvs1:/tmp/cvs-serv29751
Modified Files:
 Tag: release22-maint
	StringIO.py 
Log Message:
It's merge time!
Backport lemburg's checkin of revision 1.20:
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.19.12.1
diff -C2 -d -r1.19 -r1.19.12.1
*** StringIO.py	2001年09月24日 17:34:52	1.19
--- StringIO.py	2002年01月28日 15:00:27	1.19.12.1
***************
*** 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))

AltStyle によって変換されたページ (->オリジナル) /