diff options
author | Marc-André Lemburg <mal@egenix.com> | 2001-09-24 17:34:52 (GMT) |
---|---|---|
committer | Marc-André Lemburg <mal@egenix.com> | 2001-09-24 17:34:52 (GMT) |
commit | e47df7a2117c14eb5b0445a3002766d54e75278d (patch) | |
tree | 70a9a43eeaab6f4eb849c4e5060eef06c469b60d /Lib/StringIO.py | |
parent | c72d4cddc989a66da1f56f59bc3fc7c37df28915 (diff) | |
download | cpython-e47df7a2117c14eb5b0445a3002766d54e75278d.zip cpython-e47df7a2117c14eb5b0445a3002766d54e75278d.tar.gz cpython-e47df7a2117c14eb5b0445a3002766d54e75278d.tar.bz2 |
StringIO patch #462596: let's [c]StringIO accept read buffers on
input to .write() too.
Diffstat (limited to 'Lib/StringIO.py')
-rw-r--r-- | Lib/StringIO.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/Lib/StringIO.py b/Lib/StringIO.py index cb7313d..e7c8e04 100644 --- a/Lib/StringIO.py +++ b/Lib/StringIO.py @@ -38,7 +38,8 @@ __all__ = ["StringIO"] class StringIO: def __init__(self, buf = ''): - self.buf = buf + # Force self.buf to be a string + self.buf = str(buf) self.len = len(buf) self.buflist = [] self.pos = 0 @@ -134,6 +135,8 @@ class StringIO: if self.closed: raise ValueError, "I/O operation on closed file" if not s: return + # Force s to be a string + s = str(s) if self.pos > self.len: self.buflist.append('\0'*(self.pos - self.len)) self.len = self.pos |