File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change 3939class StringIO :
4040 def __init__ (self , buf = '' ):
4141 # Force self.buf to be a string or unicode
42- if not isinstance (buf , types .UnicodeType ):
42+ if not isinstance (buf , types .StringTypes ):
4343 buf = str (buf )
4444 self .buf = buf
4545 self .len = len (buf )
@@ -138,7 +138,7 @@ def write(self, s):
138138 raise ValueError , "I/O operation on closed file"
139139 if not s : return
140140 # Force s to be a string or unicode
141- if not isinstance (s , types .UnicodeType ):
141+ if not isinstance (s , types .StringTypes ):
142142 s = str (s )
143143 if self .pos > self .len :
144144 self .buflist .append ('\0 ' * (self .pos - self .len ))
Original file line number Diff line number Diff line change @@ -73,6 +73,8 @@ class TestStringIO(TestGenericStringIO):
7373
7474 def test_unicode (self ):
7575
76+ if not test_support .have_unicode : return
77+
7678 # The StringIO module also supports concatenating Unicode
7779 # snippets to larger Unicode strings. This is tested by this
7880 # method. Note that cStringIO does not support this extension.
You can’t perform that action at this time.
0 commit comments