Skip to content

Commit 177196d

Browse files
committed
catch OSError on Windows
1 parent 37f0997 commit 177196d

2 files changed

Lines changed: 3 additions & 7 deletions

File tree

src/itsdangerous/timed.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,8 +38,7 @@ def get_timestamp(self) -> int:
3838

3939
def timestamp_to_datetime(self, ts: int) -> datetime:
4040
"""Convert the timestamp from :meth:`get_timestamp` into an
41-
aware :class`datetime.datetime` in UTC. Raises :exc:`.ValueError`
42-
if the timestamp is too far in the past or future for Python.
41+
aware :class`datetime.datetime` in UTC.
4342
4443
.. versionchanged:: 2.0
4544
The timestamp is returned as a timezone-aware ``datetime``
@@ -127,7 +126,8 @@ def unsign(
127126
if ts_int is not None:
128127
try:
129128
ts_dt = self.timestamp_to_datetime(ts_int)
130-
except ValueError as exc:
129+
except (ValueError, OSError) as exc:
130+
# Windows raises OSError
131131
raise BadTimeSignature(
132132
"Malformed timestamp", payload=value
133133
) from exc

tests/test_itsdangerous/test_timed.py

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
import sys
21
from datetime import datetime
32
from datetime import timedelta
43
from datetime import timezone
@@ -67,9 +66,6 @@ def test_malformed_timestamp(self, signer):
6766
assert "Malformed" in str(exc_info.value)
6867
assert exc_info.value.date_signed is None
6968

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

0 commit comments

Comments
 (0)