]> granicus.if.org Git - python/commitdiff
SF Patch #494863, file.xreadlines() should raise ValueError if file is closed
authorNeal Norwitz <nnorwitz@gmail.com>
Tue, 1 Jan 2002 19:07:13 +0000 (19:07 +0000)
committerNeal Norwitz <nnorwitz@gmail.com>
Tue, 1 Jan 2002 19:07:13 +0000 (19:07 +0000)
This makes xreadlines behave like all other file methods
(other than close() which just returns).

Misc/NEWS
Objects/fileobject.c

index 8d68533ad0248c8c7752a235ac4ce9372df52291..9ef6912fbd14d485b45c5488a5386d467ddda088 100644 (file)
--- 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
index 27612f491edc78efbcd992939729885d2573c450..9af5ca985cef9d26af3f20ae76d33659d9ef429e 100644 (file)
@@ -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");