Skip to content
Merged
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
1 change: 1 addition & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
## Not released

- Dropped Python 3.9 and 3.10 support due to the EOL.
- Fixed `expire_after` datetimes with a non-UTC timezone, which lost their UTC offset instead of being converted to UTC.
- Fixed cache key collisions between distinct JSON request bodies. Cache keys now use the
configured JSON serializer, including bytes serializers.
- Fixed cache key collisions between request bodies, such as `data=b'false'` and `json=False`, and between request bodies and headers. Existing cache entries won't be reused after upgrading.
Expand Down
3 changes: 1 addition & 2 deletions aiohttp_client_cache/cache_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -243,8 +243,7 @@ def convert_to_utc_naive(dt: datetime):
datetimes to the same format.
"""
if dt.tzinfo:
dt.astimezone(UTC)
dt = dt.replace(tzinfo=None)
dt = dt.astimezone(UTC).replace(tzinfo=None)
return dt


Expand Down
6 changes: 5 additions & 1 deletion test/unit/test_cache_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import os
from collections.abc import Mapping
from contextlib import nullcontext
from datetime import UTC, datetime, timedelta
from datetime import UTC, datetime, timedelta, timezone
from email.utils import format_datetime
from typing import Any
from unittest.mock import MagicMock, patch
Expand Down Expand Up @@ -333,6 +333,10 @@ def test_split_kv_directive(value, expected_output) -> None:
RANDOM_DATETIME_NOW_UTC.replace(tzinfo=None),
RANDOM_DATETIME_NOW_UTC.replace(tzinfo=None),
),
(
datetime(2026, 1, 1, 12, tzinfo=timezone(timedelta(hours=2))),
datetime(2026, 1, 1, 10),
),
],
)
def test_convert_to_utc_naive(dt: datetime, dt_utc: datetime) -> None:
Expand Down
Loading