Skip to content

Commit 2638ef8

Browse files
author
georg.brandl
committed
Bug #1674503: close the file opened by execfile() in an error condition.
git-svn-id: http://svn.python.org/projects/python/trunk@54159 6015fed2-1504-0410-9fe1-9d1591cc4771
1 parent 648460b commit 2638ef8

2 files changed

Lines changed: 4 additions & 2 deletions

File tree

Misc/NEWS

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1?
1212
Core and builtins
1313
-----------------
1414

15+
- Bug #1674503: close the file opened by execfile() in an error condition.
16+
1517
- Patch #1674228: when assigning a slice (old-style), check for the
1618
sq_ass_slice instead of the sq_slice slot.
1719

Python/pythonrun.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1251,12 +1251,12 @@ PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals,
12511251

12521252
mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
12531253
flags, NULL, arena);
1254+
if (closeit)
1255+
fclose(fp);
12541256
if (mod == NULL) {
12551257
PyArena_Free(arena);
12561258
return NULL;
12571259
}
1258-
if (closeit)
1259-
fclose(fp);
12601260
ret = run_mod(mod, filename, globals, locals, flags, arena);
12611261
PyArena_Free(arena);
12621262
return ret;

0 commit comments

Comments
 (0)