Skip to content

Commit

Permalink
Use consistent flush syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
moble authored and casperdcl committed Mar 23, 2022
1 parent 938b24a commit c61a567
Showing 1 changed file with 3 additions and 5 deletions.
8 changes: 3 additions & 5 deletions tqdm/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -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))
Expand Down Expand Up @@ -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):
Expand Down

0 comments on commit c61a567

Please sign in to comment.