summaryrefslogtreecommitdiffstats
path: root/Modules/_io
diff options
context:
space:
mode:
authorBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:13:56 (GMT)
committerBerker Peksag <berker.peksag@gmail.com>2015-05-12 14:13:56 (GMT)
commitea6d5592f2964a17b14c1714bb06fe01918323b5 (patch)
tree2191daef69ec1b37cceddf95bc8160388fa2051a /Modules/_io
parentb9db9e152f3325b075e59ef4fdecfd0b9ec4746c (diff)
downloadcpython-ea6d5592f2964a17b14c1714bb06fe01918323b5.zip
cpython-ea6d5592f2964a17b14c1714bb06fe01918323b5.tar.gz
cpython-ea6d5592f2964a17b14c1714bb06fe01918323b5.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/_io')
-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 3606cc8..365bb85 100644
--- a/Modules/_io/bufferedio.c
+++ b/Modules/_io/bufferedio.c
@@ -889,6 +889,8 @@ buffered_peek(buffered *self, PyObject *args)
PyObject *res = NULL;
CHECK_INITIALIZED(self)
+ CHECK_CLOSED(self, "peek of closed file")
+
if (!PyArg_ParseTuple(args, "|n:peek", &n)) {
return NULL;
}
@@ -963,6 +965,9 @@ buffered_read1(buffered *self, PyObject *args)
"read length must be positive");
return NULL;
}
+
+ CHECK_CLOSED(self, "read of closed file")
+
if (n == 0)
return PyBytes_FromStringAndSize(NULL, 0);