bpo-45410: regrtest -W leaves stdout/err FD unchanged (GH-28915)

support.print_warning() now stores the original value of
sys.__stderr__ and uses it to log warnings. libregrtest uses the same
stream to log unraisable exceptions and uncaught threading
exceptions.

Partially revert commit dbe213de7e:
libregrtest no longer replaces sys.__stdout__, sys.__stderr__, and
stdout and stderr file descriptors.

Remove also a few unused imports in libregrtest.
This commit is contained in:
Victor Stinner 2021-10-13 14:08:18 +02:00 committed by GitHub
parent 380c440875
commit 7733307739
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
7 changed files with 19 additions and 82 deletions

View file

@ -75,7 +75,7 @@ def regrtest_unraisable_hook(unraisable):
old_stderr = sys.stderr
try:
support.flush_std_streams()
sys.stderr = sys.__stderr__
sys.stderr = support.print_warning.orig_stderr
orig_unraisablehook(unraisable)
sys.stderr.flush()
finally:
@ -98,7 +98,7 @@ def regrtest_threading_excepthook(args):
old_stderr = sys.stderr
try:
support.flush_std_streams()
sys.stderr = sys.__stderr__
sys.stderr = support.print_warning.orig_stderr
orig_threading_excepthook(args)
sys.stderr.flush()
finally: