Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
C
cpython
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
Analytics
Analytics
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Commits
Issue Boards
Open sidebar
Kirill Smelkov
cpython
Commits
6b3a2c4a
Commit
6b3a2c4a
authored
Aug 08, 2001
by
Martin v. Löwis
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Patch #448227: Raise an exception when a directory is passed to execfile.
parent
96204f5e
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
4 deletions
+23
-4
Python/bltinmodule.c
Python/bltinmodule.c
+23
-4
No files found.
Python/bltinmodule.c
View file @
6b3a2c4a
...
...
@@ -568,6 +568,8 @@ builtin_execfile(PyObject *self, PyObject *args)
PyObject
*
res
;
FILE
*
fp
;
PyCompilerFlags
cf
;
int
exists
;
struct
stat
s
;
if
(
!
PyArg_ParseTuple
(
args
,
"s|O!O!:execfile"
,
&
filename
,
...
...
@@ -586,10 +588,27 @@ builtin_execfile(PyObject *self, PyObject *args)
PyEval_GetBuiltins
())
!=
0
)
return
NULL
;
}
Py_BEGIN_ALLOW_THREADS
fp
=
fopen
(
filename
,
"r"
);
Py_END_ALLOW_THREADS
if
(
fp
==
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
;
}
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment