diff options
author | Guido van Rossum <guido@python.org> | 1998-10-02 01:23:47 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 1998-10-02 01:23:47 (GMT) |
commit | 64e736ba4e8c7d706f705e1e34a24f8e24d285d6 (patch) | |
tree | a097506524d3530d65427918ce01171bb5ac2e8d /Lib/dos-8x3/stringio.py | |
parent | fdb8fb8b312bb9814bca5c153c8246fed2156c81 (diff) | |
download | cpython-64e736ba4e8c7d706f705e1e34a24f8e24d285d6.zip cpython-64e736ba4e8c7d706f705e1e34a24f8e24d285d6.tar.gz cpython-64e736ba4e8c7d706f705e1e34a24f8e24d285d6.tar.bz2 |
Some new blood and some updated versions.
Diffstat (limited to 'Lib/dos-8x3/stringio.py')
-rwxr-xr-x | Lib/dos-8x3/stringio.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/Lib/dos-8x3/stringio.py b/Lib/dos-8x3/stringio.py index dba38e4..fc195b9 100755 --- a/Lib/dos-8x3/stringio.py +++ b/Lib/dos-8x3/stringio.py @@ -41,8 +41,12 @@ class StringIO: self.closed = 1 del self.buf, self.pos def isatty(self): + if self.closed: + raise ValueError, "I/O operation on closed file" return 0 def seek(self, pos, mode = 0): + if self.closed: + raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] @@ -52,8 +56,12 @@ class StringIO: pos = pos + self.len self.pos = max(0, pos) def tell(self): + if self.closed: + raise ValueError, "I/O operation on closed file" return self.pos def read(self, n = -1): + if self.closed: + raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] @@ -65,6 +73,8 @@ class StringIO: self.pos = newpos return r def readline(self, length=None): + if self.closed: + raise ValueError, "I/O operation on closed file" if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') self.buflist = [] @@ -87,6 +97,8 @@ class StringIO: line = self.readline() return lines def write(self, s): + if self.closed: + raise ValueError, "I/O operation on closed file" if not s: return if self.pos > self.len: self.buflist.append('\0'*(self.pos - self.len)) @@ -105,7 +117,8 @@ class StringIO: def writelines(self, list): self.write(string.joinfields(list, '')) def flush(self): - pass + if self.closed: + raise ValueError, "I/O operation on closed file" def getvalue(self): if self.buflist: self.buf = self.buf + string.joinfields(self.buflist, '') |