[Python-checkins] CVS: python/dist/src/Objects fileobject.c,2.103,2.104

Guido van Rossum python-dev@python.org
Tue, 09 Jan 2001 13:50:27 -0800


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv18990

Modified Files:
	fileobject.c 
Log Message:
Jeff Epler's patch adding an xreadlines() method.  (It just imports
the xreadlines module and lets it do its thing.)


Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.103
retrieving revision 2.104
diff -C2 -r2.103 -r2.104
*** fileobject.c	2001/01/09 02:00:11	2.103
--- fileobject.c	2001/01/09 21:50:24	2.104
***************
*** 965,968 ****
--- 965,991 ----
  
  static PyObject *
+ file_xreadlines(PyFileObject *f, PyObject *args)
+ {
+ 	static PyObject* xreadlines_function = NULL;
+ 	
+ 	if (!PyArg_ParseTuple(args, ":xreadlines"))
+ 		return NULL;
+ 	
+ 	if (!xreadlines_function) {
+ 		PyObject *xreadlines_module =
+ 			PyImport_ImportModule("xreadlines");
+ 		if(!xreadlines_module)
+ 			return NULL;
+ 
+ 		xreadlines_function = PyObject_GetAttrString(xreadlines_module,
+ 							     "xreadlines");
+ 		Py_DECREF(xreadlines_module);
+ 		if(!xreadlines_function)
+ 			return NULL;
+ 	}
+ 	return PyObject_CallFunction(xreadlines_function, "(O)", f);
+ }
+ 
+ static PyObject *
  file_readlines(PyFileObject *f, PyObject *args)
  {
***************
*** 1010,1014 ****
  			if (buffersize > INT_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 					"line is longer than a Python string can hold");
  				goto error;
  			}
--- 1033,1037 ----
  			if (buffersize > INT_MAX) {
  				PyErr_SetString(PyExc_OverflowError,
! 			    "line is longer than a Python string can hold");
  				goto error;
  			}
***************
*** 1233,1236 ****
--- 1256,1260 ----
  	{"readinto",	(PyCFunction)file_readinto, 0},
  	{"readlines",	(PyCFunction)file_readlines, 1},
+ 	{"xreadlines",	(PyCFunction)file_xreadlines, 1},
  	{"writelines",	(PyCFunction)file_writelines, 0},
  	{"flush",	(PyCFunction)file_flush, 0},