Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit e037665

Browse files
committed
Use isinstance() in preference to comparison of type by is.
1 parent fad2f59 commit e037665

1 file changed

Lines changed: 2 additions & 2 deletions

File tree

Lib/StringIO.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@
3939
class StringIO:
4040
def __init__(self, buf = ''):
4141
# Force self.buf to be a string or unicode
42-
if type(buf) is not types.UnicodeType:
42+
if not isinstance(buf, types.UnicodeType):
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 type(s) is not types.UnicodeType:
141+
if not isinstance(s, types.UnicodeType):
142142
s = str(s)
143143
if self.pos > self.len:
144144
self.buflist.append('\0'*(self.pos - self.len))

0 commit comments

Comments
 (0)