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

Jeremy Hylton jhylton@users.sourceforge.net
Fri, 09 Nov 2001 08:17:26 -0800


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

Modified Files:
	fileobject.c 
Log Message:
Fix SF buf #476953: Bad more for opening file gives bad msg.

If fopen() fails with EINVAL it means that the mode argument is
invalid.  Return the mode in the error message instead of the
filename.


Index: fileobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/fileobject.c,v
retrieving revision 2.136
retrieving revision 2.137
diff -C2 -d -r2.136 -r2.137
*** fileobject.c	2001/10/31 18:51:01	2.136
--- fileobject.c	2001/11/09 16:17:24	2.137
***************
*** 122,126 ****
  #ifdef NO_FOPEN_ERRNO
  		/* Metroworks only, not testable, so unchanged */
! 		if ( errno == 0 ) {
  			PyErr_SetString(PyExc_IOError, "Cannot open file");
  			Py_DECREF(f);
--- 122,126 ----
  #ifdef NO_FOPEN_ERRNO
  		/* Metroworks only, not testable, so unchanged */
! 		if (errno == 0) {
  			PyErr_SetString(PyExc_IOError, "Cannot open file");
  			Py_DECREF(f);
***************
*** 128,132 ****
  		}
  #endif
! 		PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
  		f = NULL;
  	}
--- 128,136 ----
  		}
  #endif
! 		if (errno == EINVAL)
! 			PyErr_Format(PyExc_IOError, "invalid argument: %s",
! 				     mode);
! 		else
! 			PyErr_SetFromErrnoWithFilename(PyExc_IOError, name);
  		f = NULL;
  	}