mirror of
https://github.com/python/cpython.git
synced 2025-08-03 16:39:00 +00:00
bpo-45410: Add test.support.flush_std_streams() (GH-28885)
support.print_warning() now flushs sys.stdout.
This commit is contained in:
parent
47717d1186
commit
1ebd798fdd
3 changed files with 20 additions and 9 deletions
|
@ -68,20 +68,13 @@ def print_warning(msg):
|
|||
orig_unraisablehook = None
|
||||
|
||||
|
||||
def flush_std_streams():
|
||||
if sys.stdout is not None:
|
||||
sys.stdout.flush()
|
||||
if sys.stderr is not None:
|
||||
sys.stderr.flush()
|
||||
|
||||
|
||||
def regrtest_unraisable_hook(unraisable):
|
||||
global orig_unraisablehook
|
||||
support.environment_altered = True
|
||||
print_warning("Unraisable exception")
|
||||
old_stderr = sys.stderr
|
||||
try:
|
||||
flush_std_streams()
|
||||
support.flush_std_streams()
|
||||
sys.stderr = sys.__stderr__
|
||||
orig_unraisablehook(unraisable)
|
||||
sys.stderr.flush()
|
||||
|
@ -104,7 +97,7 @@ def regrtest_threading_excepthook(args):
|
|||
print_warning(f"Uncaught thread exception: {args.exc_type.__name__}")
|
||||
old_stderr = sys.stderr
|
||||
try:
|
||||
flush_std_streams()
|
||||
support.flush_std_streams()
|
||||
sys.stderr = sys.__stderr__
|
||||
orig_threading_excepthook(args)
|
||||
sys.stderr.flush()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue