[Python-checkins] CVS: python/dist/src/Python bltinmodule.c,2.222,2.223
Martin v. L?wis
loewis@users.sourceforge.net
Tue, 07 Aug 2001 22:30:38 -0700
Update of /cvsroot/python/python/dist/src/Python
In directory usw-pr-cvs1:/tmp/cvs-serv29148
Modified Files:
bltinmodule.c
Log Message:
Patch #448227: Raise an exception when a directory is passed to execfile.
Index: bltinmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Python/bltinmodule.c,v
retrieving revision 2.222
retrieving revision 2.223
diff -C2 -d -r2.222 -r2.223
*** bltinmodule.c 2001/08/02 04:15:00 2.222
--- bltinmodule.c 2001/08/08 05:30:36 2.223
***************
*** 569,572 ****
--- 569,574 ----
FILE* fp;
PyCompilerFlags cf;
+ int exists;
+ struct stat s;
if (!PyArg_ParseTuple(args, "s|O!O!:execfile",
***************
*** 587,594 ****
return NULL;
}
! Py_BEGIN_ALLOW_THREADS
! fp = fopen(filename, "r");
! Py_END_ALLOW_THREADS
! if (fp == NULL) {
PyErr_SetFromErrno(PyExc_IOError);
return NULL;
--- 589,613 ----
return NULL;
}
!
! exists = 0;
! /* Test for existence or directory. */
! if (!stat(filename, &s)) {
! if (S_ISDIR(s.st_mode))
! errno = EISDIR;
! else
! exists = 1;
! }
!
! if (exists) {
! Py_BEGIN_ALLOW_THREADS
! fp = fopen(filename, "r");
! Py_END_ALLOW_THREADS
!
! if (fp == NULL) {
! exists = 0;
! }
! }
!
! if (!exists) {
PyErr_SetFromErrno(PyExc_IOError);
return NULL;