]> granicus.if.org Git - python/commitdiff
Use isinstance() in preference to comparison of type by is.
authorJeremy Hylton <jeremy@alum.mit.edu>
Fri, 10 May 2002 21:00:35 +0000 (21:00 +0000)
committerJeremy Hylton <jeremy@alum.mit.edu>
Fri, 10 May 2002 21:00:35 +0000 (21:00 +0000)
Lib/StringIO.py

index cc88e9de4d8f8af4b6f893af5e2ea7179a09891d..9225c0528647ba23da9e9ea2983daba3be42bf9f 100644 (file)
@@ -39,7 +39,7 @@ __all__ = ["StringIO"]
 class StringIO:
     def __init__(self, buf = ''):
         # Force self.buf to be a string or unicode
-        if type(buf) is not types.UnicodeType:
+        if not isinstance(buf, types.UnicodeType):
             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 type(s) is not types.UnicodeType:
+        if not isinstance(s, types.UnicodeType):
             s = str(s)
         if self.pos > self.len:
             self.buflist.append('\0'*(self.pos - self.len))