diff options
author | Guido van Rossum <guido@python.org> | 2000-08-27 19:21:52 (GMT) |
---|---|---|
committer | Guido van Rossum <guido@python.org> | 2000-08-27 19:21:52 (GMT) |
commit | 0df002c45b0bf2bf23bb8c0a395e86f907a94d81 (patch) | |
tree | 2812bdefa81aca791ce27544f424271e5f857c67 /Modules/main.c | |
parent | 2f15b25da2060ab723e0bb82a8f4f713d547b2b8 (diff) | |
download | cpython-0df002c45b0bf2bf23bb8c0a395e86f907a94d81.zip cpython-0df002c45b0bf2bf23bb8c0a395e86f907a94d81.tar.gz cpython-0df002c45b0bf2bf23bb8c0a395e86f907a94d81.tar.bz2 |
Add three new APIs: PyRun_AnyFileEx(), PyRun_SimpleFileEx(),
PyRun_FileEx(). These are the same as their non-Ex counterparts but
have an extra argument, a flag telling them to close the file when
done.
Then this is used by Py_Main() and execfile() to close the file after
it is parsed but before it is executed.
Adding APIs seems strange given the feature freeze but it's the only
way I see to close the bug report without incompatible changes.
[ Bug #110616 ] source file stays open after parsing is done (PR#209)
Diffstat (limited to 'Modules/main.c')
-rw-r--r-- | Modules/main.c | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Modules/main.c b/Modules/main.c index 34e99b9..9afe80b 100644 --- a/Modules/main.c +++ b/Modules/main.c @@ -268,11 +268,10 @@ Py_Main(int argc, char **argv) } } } - sts = PyRun_AnyFile( + sts = PyRun_AnyFileEx( fp, - filename == NULL ? "<stdin>" : filename) != 0; - if (filename != NULL) - fclose(fp); + filename == NULL ? "<stdin>" : filename, + filename != NULL) != 0; } if (inspect && stdin_is_interactive && |