mirror of
https://github.com/python/cpython.git
synced 2025-10-17 20:28:43 +00:00
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)
This commit is contained in:
parent
2f15b25da2
commit
0df002c45b
4 changed files with 41 additions and 15 deletions
|
@ -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 &&
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue