summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:01:05 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:01:05 (GMT)
commitd10d6ae2fad2c1963e119ed7bc031b723603b363 (patch)
treef20bea510727f668e68c89320a18a8a81c8ba36f /Modules
parent1aa5e1d63e6452234065e73e59b9f4db2c2efdeb (diff)
downloadcpython-d10d6ae2fad2c1963e119ed7bc031b723603b363.zip
cpython-d10d6ae2fad2c1963e119ed7bc031b723603b363.tar.gz
cpython-d10d6ae2fad2c1963e119ed7bc031b723603b363.tar.bz2
Issue #23796: peak and read1 methods of BufferedReader now raise ValueError
if they called on a closed object. Patch by John Hergenroeder.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_io/bufferedio.c5
1 files changed, 5 insertions, 0 deletions
diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c
index 2c90648..23ba3df 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -871,6 +871,8 @@ _io__Buffered_peek_impl(buffered *self, Py_ssize_t size)
PyObject *res = NULL;
CHECK_INITIALIZED(self)
+ CHECK_CLOSED(self, "peek of closed file")
+
if (!ENTER_BUFFERED(self))
return NULL;
@@ -947,6 +949,9 @@ _io__Buffered_read1_impl(buffered *self, Py_ssize_t n)
"read length must be positive");
return NULL;
}
+
+ CHECK_CLOSED(self, "read of closed file")
+
if (n == 0)
return PyBytes_FromStringAndSize(NULL, 0);