diff Python/pythonrun.c @ 41018:5c08e6460dc5 legacy-trunk

Bug #1674503: close the file opened by execfile() in an error condition.
author Georg Brandl <georg@python.org>
date Tue, 06 Mar 2007 12:17:50 +0000
parents 86ab2f20a333
children 728c60e85efa
line wrap: on
line diff
--- a/Python/pythonrun.c	Tue Mar 06 11:52:24 2007 +0000
+++ b/Python/pythonrun.c	Tue Mar 06 12:17:50 2007 +0000
@@ -1251,12 +1251,12 @@
 	
 	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;