? fastnames-inprogress.diff ? iters ? nohup.out ? Include/iterobject.h.stopped ? Include/stringobject.h.altinter ? Lib/test/asd ? Lib/test/foo ? Lib/test/test_class.py.xrange ? Lib/test/test_repr.py.xrange ? Lib/test/tests ? Lib/test/timing ? Lib/test/timing.sorted ? Objects/iterobject.c.stopped ? Objects/nohup.out ? Objects/sliceobject.c.open ? Objects/stringobject.c.altintern ? Objects/stringobject.c.beforerefcnt ? Objects/stringobject.c.my ? Python/ceval.c.instrumented Index: Include/fileobject.h =================================================================== RCS file: /cvsroot/python/python/dist/src/Include/fileobject.h,v retrieving revision 2.29 diff -c -r2.29 fileobject.h *** Include/fileobject.h 24 May 2002 15:24:38 -0000 2.29 --- Include/fileobject.h 16 Jul 2002 04:57:25 -0000 *************** *** 16,21 **** --- 16,22 ---- int f_softspace; /* Flag used by 'print' command */ int f_binary; /* Flag which indicates whether the file is open open in binary (1) or test (0) mode */ + PyObject *f_xreadlines; /* Cached xreadlines object */ #ifdef WITH_UNIVERSAL_NEWLINES int f_univ_newline; /* Handle any newline convention */ int f_newlinetypes; /* Types of newlines seen */ Index: Objects/fileobject.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v retrieving revision 2.165 diff -c -r2.165 fileobject.c *** Objects/fileobject.c 14 Jul 2002 22:14:19 -0000 2.165 --- Objects/fileobject.c 16 Jul 2002 04:57:38 -0000 *************** *** 283,288 **** --- 283,289 ---- } Py_XDECREF(f->f_name); Py_XDECREF(f->f_mode); + Py_XDECREF(f->f_xreadlines); f->ob_type->tp_free((PyObject *)f); } *************** *** 405,410 **** --- 406,413 ---- if (f->f_fp == NULL) return err_closed(); + Py_XDECREF(f->f_xreadlines); /* Invalidate cached xreadlines */ + f->f_xreadlines = NULL; whence = 0; if (!PyArg_ParseTuple(args, "O|i:seek", &offobj, &whence)) return NULL; *************** *** 1180,1192 **** static PyObject * 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"); if(!xreadlines_module) return NULL; --- 1183,1196 ---- static PyObject * file_xreadlines(PyFileObject *f) { ! PyObject *xreadlines_module; ! PyObject* xreadlines_function; if (f->f_fp == NULL) return err_closed(); ! ! if (f->f_xreadlines == NULL) { ! xreadlines_module = PyImport_ImportModule("xreadlines"); if(!xreadlines_module) return NULL; *************** *** 1195,1202 **** Py_DECREF(xreadlines_module); if(!xreadlines_function) return NULL; } ! return PyObject_CallFunction(xreadlines_function, "(O)", f); } static PyObject * --- 1199,1229 ---- Py_DECREF(xreadlines_module); if(!xreadlines_function) return NULL; + + f->f_xreadlines = + PyObject_CallFunction(xreadlines_function, "(O)", f); + Py_DECREF(xreadlines_function); + } + Py_INCREF(f->f_xreadlines); + return f->f_xreadlines; + } + + static PyObject * + file_next(PyObject *f) + { + PyObject* x; + static iternextfunc xreadlines_next = NULL; + + x = ((PyFileObject *)f)->f_xreadlines; + if (x == NULL) { + x = file_xreadlines((PyFileObject *)f); + if (x == NULL) + return NULL; + if (xreadlines_next == NULL) { + xreadlines_next = x->ob_type->tp_iternext; + } } ! return xreadlines_next(x); } static PyObject * *************** *** 1620,1626 **** static PyObject * file_getiter(PyObject *f) { ! return PyObject_CallMethod(f, "xreadlines", ""); } static PyObject * --- 1647,1654 ---- static PyObject * file_getiter(PyObject *f) { ! Py_INCREF(f); ! return f; } static PyObject * *************** *** 1743,1749 **** 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ file_getiter, /* tp_iter */ ! 0, /* tp_iternext */ file_methods, /* tp_methods */ file_memberlist, /* tp_members */ file_getsetlist, /* tp_getset */ --- 1771,1777 ---- 0, /* tp_richcompare */ 0, /* tp_weaklistoffset */ file_getiter, /* tp_iter */ ! file_next, /* tp_iternext */ file_methods, /* tp_methods */ file_memberlist, /* tp_members */ file_getsetlist, /* tp_getset */