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

Guido van Rossum gvanrossum@users.sourceforge.net
2001年8月09日 11:15:01 -0700


Update of /cvsroot/python/python/dist/src/Objects
In directory usw-pr-cvs1:/tmp/cvs-serv27522
Modified Files:
	fileobject.c 
Log Message:
Apply anonymous SF patch #441229.
 Previously, f.read() and f.readlines() checked for 
 errors on their file object and possibly raised an 
 IOError, but f.readline() didn't. This patch makes 
 f.readline() behave like the others.
Note that I've added a call to clearerr() since the other calls to
ferror() include that too.
I have no way to test this code. :-)
Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.116
retrieving revision 2.117
diff -C2 -d -r2.116 -r2.117
*** fileobject.c	2001年08月06日 18:51:38	2.116
--- fileobject.c	2001年08月09日 18:14:59	2.117
***************
*** 848,851 ****
--- 848,857 ----
 			break;
 		if (c == EOF) {
+ 			if (ferror(fp)) {
+ 				PyErr_SetFromErrno(PyExc_IOError);
+ 				clearerr(fp);
+ 				Py_DECREF(v);
+ 				return NULL;
+ 			}
 			clearerr(fp);
 			if (PyErr_CheckSignals()) {

AltStyle によって変換されたページ (->オリジナル) /