summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Misc/NEWS4
-rw-r--r--Objects/fileobject.c2
2 files changed, 6 insertions, 0 deletions
diff --git a/Misc/NEWS b/Misc/NEWS
index 8d68533..9ef6912 100644
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -6,6 +6,10 @@ Type/class unification and new-style classes
Core and builtins
+- file.xreadlines() now raises a ValueError if the file is closed:
+ Previously, an xreadlines object was returned which would raise
+ a ValueError when the xreadlines.next() method was called.
+
Extension modules
Library
diff --git a/Objects/fileobject.c b/Objects/fileobject.c
index 27612f4..9af5ca9 100644
--- a/Objects/fileobject.c
+++ b/Objects/fileobject.c
@@ -1025,6 +1025,8 @@ file_xreadlines(PyFileObject *f)
{
static PyObject* xreadlines_function = NULL;
+ if (f->f_fp == NULL)
+ return err_closed();
if (!xreadlines_function) {
PyObject *xreadlines_module =
PyImport_ImportModule("xreadlines");