]> granicus.if.org Git - python/commitdiff
Make StringIO work in --disable-unicode builds...
authorMichael W. Hudson <mwh@python.net>
Mon, 13 May 2002 09:42:16 +0000 (09:42 +0000)
committerMichael W. Hudson <mwh@python.net>
Mon, 13 May 2002 09:42:16 +0000 (09:42 +0000)
Lib/StringIO.py
Lib/test/test_StringIO.py

index 9225c0528647ba23da9e9ea2983daba3be42bf9f..38b3e368353b77a995e8e10e8443b20178cc290b 100644 (file)
@@ -39,7 +39,7 @@ __all__ = ["StringIO"]
 class StringIO:
     def __init__(self, buf = ''):
         # Force self.buf to be a string or unicode
-        if not isinstance(buf, types.UnicodeType):
+        if not isinstance(buf, types.StringTypes):
             buf = str(buf)
         self.buf = buf
         self.len = len(buf)
@@ -138,7 +138,7 @@ class StringIO:
             raise ValueError, "I/O operation on closed file"
         if not s: return
         # Force s to be a string or unicode
-        if not isinstance(s, types.UnicodeType):
+        if not isinstance(s, types.StringTypes):
             s = str(s)
         if self.pos > self.len:
             self.buflist.append('\0'*(self.pos - self.len))
index a340e3b6aeeb43da76107ff3d617245b2b488d3a..9deba0d85a36d7ef20b068fdb5580094fe17d0f0 100644 (file)
@@ -73,6 +73,8 @@ class TestStringIO(TestGenericStringIO):
 
     def test_unicode(self):
 
+        if not test_support.have_unicode: return
+
         # The StringIO module also supports concatenating Unicode
         # snippets to larger Unicode strings. This is tested by this
         # method. Note that cStringIO does not support this extension.