From c61a5679d234849343c5d5c55ae676ad14308c59 Mon Sep 17 00:00:00 2001 From: Michael Boyle Date: Mon, 13 Sep 2021 12:08:47 -0400 Subject: [PATCH] Use consistent flush syntax --- tqdm/std.py | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/tqdm/std.py b/tqdm/std.py index dd54eb534..9a687391b 100644 --- a/tqdm/std.py +++ b/tqdm/std.py @@ -336,10 +336,8 @@ def status_printer(file): fp = file fp_flush = getattr(fp, 'flush', lambda: None) # pragma: no cover if fp in (sys.stderr, sys.stdout): - if hasattr(sys.stderr, 'flush'): - sys.stderr.flush() - if hasattr(sys.stdout, 'flush'): - sys.stdout.flush() + getattr(sys.stderr, 'flush', lambda: None)() + getattr(sys.stdout, 'flush', lambda: None)() def fp_write(s): fp.write(_unicode(s)) @@ -1457,7 +1455,7 @@ def set_postfix_str(self, s='', refresh=True): def moveto(self, n): # TODO: private method self.fp.write(_unicode('\n' * n + _term_move_up() * -n)) - self.fp.flush() + getattr(self.fp, 'flush', lambda: None)() @property def format_dict(self):