Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion src/check_jsonschema/cachedownloader.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from __future__ import annotations

import calendar
import contextlib
import hashlib
import io
Expand Down Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions tests/unit/test_cachedownloader.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
Loading