From: Jeremy Hylton Date: Fri, 10 May 2002 21:00:35 +0000 (+0000) Subject: Use isinstance() in preference to comparison of type by is. X-Git-Tag: v2.3c1~5694 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=e037665f999c2ab5637fd9c2f4ac5c24e44e48f0;p=python Use isinstance() in preference to comparison of type by is. --- diff --git a/Lib/StringIO.py b/Lib/StringIO.py index cc88e9de4d..9225c05286 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -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))