Mercurial > cpython-lru_cache-weakref
diff Lib/StringIO.py @ 20060:ccec02bfe9a0 legacy-trunk
StringIO patch #462596: let's [c]StringIO accept read buffers on
input to .write() too.
| author | Marc-André Lemburg <mal@egenix.com> |
|---|---|
| date | Mon, 24 Sep 2001 17:34:52 +0000 |
| parents | 5c9a955ef17c |
| children | 6b0e16cb65d5 |
line wrap: on
line diff
--- a/Lib/StringIO.py Mon Sep 24 17:29:09 2001 +0000 +++ b/Lib/StringIO.py Mon Sep 24 17:34:52 2001 +0000 @@ -38,7 +38,8 @@ 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 @@ 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
