Skip to content

Commit

Permalink
catch OSError on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
davidism committed Mar 9, 2022
1 parent 37f0997 commit 177196d
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 7 deletions.
6 changes: 3 additions & 3 deletions src/itsdangerous/timed.py
Expand Up @@ -38,8 +38,7 @@ def get_timestamp(self) -> int:

def timestamp_to_datetime(self, ts: int) -> datetime:
"""Convert the timestamp from :meth:`get_timestamp` into an
aware :class`datetime.datetime` in UTC. Raises :exc:`.ValueError`
if the timestamp is too far in the past or future for Python.
aware :class`datetime.datetime` in UTC.
.. versionchanged:: 2.0
The timestamp is returned as a timezone-aware ``datetime``
Expand Down Expand Up @@ -127,7 +126,8 @@ def unsign(
if ts_int is not None:
try:
ts_dt = self.timestamp_to_datetime(ts_int)
except ValueError as exc:
except (ValueError, OSError) as exc:
# Windows raises OSError
raise BadTimeSignature(
"Malformed timestamp", payload=value
) from exc
Expand Down
4 changes: 0 additions & 4 deletions tests/test_itsdangerous/test_timed.py
@@ -1,4 +1,3 @@
import sys
from datetime import datetime
from datetime import timedelta
from datetime import timezone
Expand Down Expand Up @@ -67,9 +66,6 @@ def test_malformed_timestamp(self, signer):
assert "Malformed" in str(exc_info.value)
assert exc_info.value.date_signed is None

@pytest.mark.skipif(
sys.platform == "win32", reason="Freezegun Invalid argument occurs on Windows"
)
def test_malformed_future_timestamp(self, signer):
signed = b"value.TgPVoaGhoQ.AGBfQ6G6cr07byTRt0zAdPljHOY"

Expand Down

0 comments on commit 177196d

Please sign in to comment.