Kaydet (Commit) 649b7595 authored tarafından Neal Norwitz's avatar Neal Norwitz

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).
üst a6e97580
...@@ -6,6 +6,10 @@ Type/class unification and new-style classes ...@@ -6,6 +6,10 @@ Type/class unification and new-style classes
Core and builtins 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 Extension modules
Library Library
......
...@@ -1025,6 +1025,8 @@ file_xreadlines(PyFileObject *f) ...@@ -1025,6 +1025,8 @@ file_xreadlines(PyFileObject *f)
{ {
static PyObject* xreadlines_function = NULL; static PyObject* xreadlines_function = NULL;
if (f->f_fp == NULL)
return err_closed();
if (!xreadlines_function) { if (!xreadlines_function) {
PyObject *xreadlines_module = PyObject *xreadlines_module =
PyImport_ImportModule("xreadlines"); PyImport_ImportModule("xreadlines");
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment