diff --git a/src/check_jsonschema/cachedownloader.py b/src/check_jsonschema/cachedownloader.py index 41cf2aae3..86aad0e62 100644 --- a/src/check_jsonschema/cachedownloader.py +++ b/src/check_jsonschema/cachedownloader.py @@ -1,5 +1,6 @@ from __future__ import annotations +import calendar import contextlib import hashlib import io @@ -43,7 +44,7 @@ def _resolve_cache_dir(dirname: str) -> str | None: def _lastmod_from_response(response: requests.Response) -> float: try: - return time.mktime( + return calendar.timegm( time.strptime(response.headers["last-modified"], _LASTMOD_FMT) ) # OverflowError: time outside of platform-specific bounds diff --git a/tests/unit/test_cachedownloader.py b/tests/unit/test_cachedownloader.py index 1a0949aed..a1c997545 100644 --- a/tests/unit/test_cachedownloader.py +++ b/tests/unit/test_cachedownloader.py @@ -274,10 +274,10 @@ def test_cachedownloader_handles_bad_lastmod_header( elif failure_mode == "time_overflow": add_default_response() - def fake_mktime(*args): + def fake_timegm(*args): raise OverflowError("uh-oh") - monkeypatch.setattr("time.mktime", fake_mktime) + monkeypatch.setattr("calendar.timegm", fake_timegm) else: raise NotImplementedError