Kaydet (Commit) e037665f authored tarafından Jeremy Hylton's avatar Jeremy Hylton

Use isinstance() in preference to comparison of type by is.

üst fad2f593
...@@ -39,7 +39,7 @@ __all__ = ["StringIO"] ...@@ -39,7 +39,7 @@ __all__ = ["StringIO"]
class StringIO: class StringIO:
def __init__(self, buf = ''): def __init__(self, buf = ''):
# Force self.buf to be a string or unicode # 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) buf = str(buf)
self.buf = buf self.buf = buf
self.len = len(buf) self.len = len(buf)
...@@ -138,7 +138,7 @@ class StringIO: ...@@ -138,7 +138,7 @@ class StringIO:
raise ValueError, "I/O operation on closed file" raise ValueError, "I/O operation on closed file"
if not s: return if not s: return
# Force s to be a string or unicode # Force s to be a string or unicode
if type(s) is not types.UnicodeType: if not isinstance(s, types.UnicodeType):
s = str(s) s = str(s)
if self.pos > self.len: if self.pos > self.len:
self.buflist.append('\0'*(self.pos - self.len)) self.buflist.append('\0'*(self.pos - self.len))
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment