From 11cb58a962d9cdc4965f900be8d0aa4ad8b8fcdd Mon Sep 17 00:00:00 2001 From: "Bernhard M. Wiedemann" Date: Thu, 19 Feb 2026 23:31:07 +0100 Subject: [PATCH 1/2] Make tests pass after year 2027 (#12088) --- CHANGES/12088.bugfix.rst | 1 + tests/test_client_functional.py | 20 ++++++++++---------- tests/test_cookiejar.py | 2 +- 3 files changed, 12 insertions(+), 11 deletions(-) create mode 100644 CHANGES/12088.bugfix.rst diff --git a/CHANGES/12088.bugfix.rst b/CHANGES/12088.bugfix.rst new file mode 100644 index 00000000000..7b206eee0dd --- /dev/null +++ b/CHANGES/12088.bugfix.rst @@ -0,0 +1 @@ +Fixed tests to pass when run after 2027-05-31 -- by :user:`bmwiedemann`. diff --git a/tests/test_client_functional.py b/tests/test_client_functional.py index e0668281934..c191ce10910 100644 --- a/tests/test_client_functional.py +++ b/tests/test_client_functional.py @@ -5450,30 +5450,30 @@ async def handler(request: web.Request) -> web.Response: # Simulate Amazon-like cookies from the issue cookies = [ "session-id=146-7423990-7621939; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; " + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; " "Secure; HttpOnly", "session-id=147-8529641-8642103; Domain=.www.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; HttpOnly", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; HttpOnly", "session-id-time=2082758401l; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; Secure", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; Secure", "session-id-time=2082758402l; Domain=.www.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/", "ubid-acbit=257-7531983-5395266; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; Secure", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; Secure", 'x-acbit="KdvJzu8W@Fx6Jj3EuNFLuP0N7OtkuCfs"; Version=1; ' "Domain=.amazon.it; Path=/; Secure; HttpOnly", "at-acbit=Atza|IwEBIM-gLr8; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; " + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; " "Secure; HttpOnly", 'sess-at-acbit="4+6VzSJPHIFD/OqO264hFxIng8Y="; ' - "Domain=.amazon.it; Expires=Mon, 31-May-2027 10:00:00 GMT; " + "Domain=.amazon.it; Expires=Mon, 31-May-3024 10:00:00 GMT; " "Path=/; Secure; HttpOnly", "lc-acbit=it_IT; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/", "i18n-prefs=EUR; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/", "av-profile=null; Domain=.amazon.it; " - "Expires=Mon, 31-May-2027 10:00:00 GMT; Path=/; Secure", + "Expires=Mon, 31-May-3024 10:00:00 GMT; Path=/; Secure", 'user-pref-token="Am81ywsJ69xObBnuJ2FbilVH0mg="; ' "Domain=.amazon.it; Path=/; Secure", ] diff --git a/tests/test_cookiejar.py b/tests/test_cookiejar.py index 9ca7bacecaf..29fe46197ef 100644 --- a/tests/test_cookiejar.py +++ b/tests/test_cookiejar.py @@ -1307,7 +1307,7 @@ def test_update_cookies_from_headers_with_attributes() -> None: "secure-cookie=value1; Secure; HttpOnly; SameSite=Strict", "expiring-cookie=value2; Max-Age=3600; Path=/app", "domain-cookie=value3; Domain=.example.com; Path=/", - "dated-cookie=value4; Expires=Wed, 09 Jun 2030 10:18:14 GMT", + "dated-cookie=value4; Expires=Wed, 09 Jun 3024 10:18:14 GMT", ] jar.update_cookies_from_headers(headers, url) From 5efc6c89616ebfe16020f28d482b8ba5cd3d811e Mon Sep 17 00:00:00 2001 From: Sam Bull Date: Thu, 19 Feb 2026 22:37:40 +0000 Subject: [PATCH 2/2] Specify types in set_parser() (#12073) --- aiohttp/client_proto.py | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/aiohttp/client_proto.py b/aiohttp/client_proto.py index 07b23c48390..f2fbe108023 100644 --- a/aiohttp/client_proto.py +++ b/aiohttp/client_proto.py @@ -1,7 +1,8 @@ import asyncio from contextlib import suppress -from typing import Any, Callable +from typing import Callable, Protocol +from ._websocket.reader import WebSocketDataQueue from .base_protocol import BaseProtocol from .client_exceptions import ( ClientConnectionError, @@ -14,6 +15,7 @@ _EXC_SENTINEL, EMPTY_BODY_STATUS_CODES, BaseTimerContext, + ErrorableProtocol, set_exception, set_result, ) @@ -22,6 +24,10 @@ from .streams import EMPTY_PAYLOAD, DataQueue, StreamReader +class _Payload(ErrorableProtocol, Protocol): + def is_eof(self) -> bool: ... + + class ResponseHandler(BaseProtocol, DataQueue[tuple[RawResponseMessage, StreamReader]]): """Helper class to adapt between Protocol and StreamReader.""" @@ -31,7 +37,7 @@ def __init__(self, loop: asyncio.AbstractEventLoop) -> None: self._should_close = False - self._payload: StreamReader | None = None + self._payload: _Payload | None = None self._skip_payload = False self._payload_parser: WebSocketReader | None = None self._data_received_cb: Callable[[], None] | None = None @@ -206,15 +212,10 @@ def set_exception( def set_parser( self, - parser: Any, - payload: Any, + parser: WebSocketReader, + payload: WebSocketDataQueue, data_received_cb: Callable[[], None] | None = None, ) -> None: - # TODO: actual types are: - # parser: WebSocketReader - # payload: WebSocketDataQueue - # but they are not generi enough - # Need an ABC for both types self._payload = payload self._payload_parser = parser self._data_received_cb = data_received_cb