summaryrefslogtreecommitdiffstats
path: root/Lib/_pyio.py
diff options
context:
space:
mode:
Diffstat (limited to 'Lib/_pyio.py')
-rw-r--r--Lib/_pyio.py5
1 files changed, 5 insertions, 0 deletions
diff --git a/Lib/_pyio.py b/Lib/_pyio.py
index 1251078..163cf9d 100644
--- a/Lib/_pyio.py
+++ b/Lib/_pyio.py
@@ -1129,6 +1129,7 @@ class BufferedReader(_BufferedIOMixin):
do at most one raw read to satisfy it. We never return more
than self.buffer_size.
"""
+ self._checkClosed("peek of closed file")
with self._read_lock:
return self._peek_unlocked(size)
@@ -1147,6 +1148,7 @@ class BufferedReader(_BufferedIOMixin):
"""Reads up to size bytes, with at most one read() system call."""
# Returns up to size bytes. If at least one byte is buffered, we
# only return buffered bytes. Otherwise, we do one raw read.
+ self._checkClosed("read of closed file")
if size < 0:
size = self.buffer_size
if size == 0:
@@ -1164,6 +1166,8 @@ class BufferedReader(_BufferedIOMixin):
def _readinto(self, buf, read1):
"""Read data into *buf* with at most one system call."""
+ self._checkClosed("readinto of closed file")
+
# Need to create a memoryview object of type 'b', otherwise
# we may not be able to assign bytes to it, and slicing it
# would create a new object.
@@ -1213,6 +1217,7 @@ class BufferedReader(_BufferedIOMixin):
def seek(self, pos, whence=0):
if whence not in valid_seek_flags:
raise ValueError("invalid whence value")
+ self._checkClosed("seek of closed file")
with self._read_lock:
if whence == 1:
pos -= len(self._read_buf) - self._read_pos