]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
Bug #1674503: close the file opened by execfile() in an error condition.
authorGeorg Brandl <georg@python.org>
Tue, 6 Mar 2007 12:17:50 +0000 (12:17 +0000)
committerGeorg Brandl <georg@python.org>
Tue, 6 Mar 2007 12:17:50 +0000 (12:17 +0000)
Misc/NEWS
Python/pythonrun.c

index 894f1cbe5073dcd0f6134306bff1c768efabee5f..ed8cec403fc008ffa50687cf697908704c355a77 100644 (file)
--- a/Misc/NEWS
+++ b/Misc/NEWS
@@ -12,6 +12,8 @@ What's New in Python 2.6 alpha 1?
 Core and builtins
 -----------------
 
+- Bug #1674503: close the file opened by execfile() in an error condition.
+
 - Patch #1674228: when assigning a slice (old-style), check for the
   sq_ass_slice instead of the sq_slice slot.
 
index 98ae1151afea2899270a4652fdef8092a14b4843..3d0c68f2a74cc17a74d283591e0e9d27c3b262d9 100644 (file)
@@ -1251,12 +1251,12 @@ PyRun_FileExFlags(FILE *fp, const char *filename, int start, PyObject *globals,
        
        mod = PyParser_ASTFromFile(fp, filename, start, 0, 0,
                                   flags, NULL, arena);
+       if (closeit)
+               fclose(fp);
        if (mod == NULL) {
                PyArena_Free(arena);
                return NULL;
        }
-       if (closeit)
-               fclose(fp);
        ret = run_mod(mod, filename, globals, locals, flags, arena);
        PyArena_Free(arena);
        return ret;