Skip to content

Commit

Permalink
Ensure that stderr/stdout has flush attr before calling it
Browse files Browse the repository at this point in the history
  • Loading branch information
moble authored and casperdcl committed Mar 23, 2022
1 parent 2527b35 commit 938b24a
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions tqdm/std.py
Original file line number Diff line number Diff line change
Expand Up @@ -336,8 +336,10 @@ def status_printer(file):
fp = file
fp_flush = getattr(fp, 'flush', lambda: None) # pragma: no cover
if fp in (sys.stderr, sys.stdout):
sys.stderr.flush()
sys.stdout.flush()
if hasattr(sys.stderr, 'flush'):
sys.stderr.flush()
if hasattr(sys.stdout, 'flush'):
sys.stdout.flush()

def fp_write(s):
fp.write(_unicode(s))
Expand Down

0 comments on commit 938b24a

Please sign in to comment.