SF Patch #494863, file.xreadlines() should raise ValueError if file is closed

This makes xreadlines behave like all other file methods
(other than close() which just returns).
This commit is contained in:
Neal Norwitz 2002-01-01 19:07:13 +00:00
parent a6e975801e
commit 649b75954a
2 changed files with 6 additions and 0 deletions

View File

@ -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

View 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");