Skip to content

Commit

Permalink
Handle OSError exception from format_time() in ETA.__call__()
Browse files Browse the repository at this point in the history
In Windows CPython, format_time() can throw "OSError: [Errno 22] Invalid argument" when passed a very large date.
Ignore this in ETA.__call__() with contextlib.suppress().  Fixes #297.
  • Loading branch information
jdykstra committed Jun 1, 2024
1 parent 5d53d59 commit abcba3a
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions progressbar/widgets.py
Original file line number Diff line number Diff line change
Expand Up @@ -547,7 +547,7 @@ def __call__(

data['eta'] = None
if data['eta_seconds']:
with contextlib.suppress(ValueError, OverflowError):
with contextlib.suppress(ValueError, OverflowError, OSError):
data['eta'] = utils.format_time(data['eta_seconds'])

if data['value'] == progress.min_value:
Expand All @@ -560,7 +560,7 @@ def __call__(
fmt = self.format_NA
else:
fmt = self.format_zero

:

Check failure

Code scanning / CodeQL

Syntax error Error

Syntax Error (in Python 3).
return Timer.__call__(self, progress, data, format=fmt)


Expand Down

0 comments on commit abcba3a

Please sign in to comment.