Kaydet (Commit) 4b2b43d9 authored tarafından Victor Stinner's avatar Victor Stinner

regrtest: close the new stdout and restore the original stdout at exit

Fix a ResourceWarning(unclosed file).
üst 358e11d9
......@@ -743,10 +743,19 @@ def replace_stdout():
if os.name == "nt":
# Replace sys.stdout breaks the stdout newlines on Windows: issue #8533
return
import atexit
stdout = sys.stdout
sys.stdout = open(stdout.fileno(), 'w',
encoding=stdout.encoding,
errors="backslashreplace")
errors="backslashreplace",
closefd=False)
def restore_stdout():
sys.stdout.close()
sys.stdout = stdout
atexit.register(restore_stdout)
def runtest(test, verbose, quiet,
huntrleaks=False, debug=False, use_resources=None):
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment