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

Skip to content

Commit e1c67d1

Browse files
author
Michael W. Hudson
committed
Make StringIO work in --disable-unicode builds...
1 parent 775c11f commit e1c67d1

2 files changed

Lines changed: 4 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 not isinstance(buf, types.UnicodeType):
42+
if not isinstance(buf, types.StringTypes):
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 not isinstance(s, types.UnicodeType):
141+
if not isinstance(s, types.StringTypes):
142142
s = str(s)
143143
if self.pos > self.len:
144144
self.buflist.append('\0'*(self.pos - self.len))

Lib/test/test_StringIO.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,8 @@ class TestStringIO(TestGenericStringIO):
7373

7474
def test_unicode(self):
7575

76+
if not test_support.have_unicode: return
77+
7678
# The StringIO module also supports concatenating Unicode
7779
# snippets to larger Unicode strings. This is tested by this
7880
# method. Note that cStringIO does not support this extension.

0 commit comments

Comments
 (0)