-
-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Closed
Labels
Description
Describe the bug
aiohttp use __setitem__
to make cookie's partitioned
attribute available in python <= 3.13 (#11112 ):
aiohttp/aiohttp/_cookie_helpers.py
Lines 274 to 275 in 230e1ee
if lower_key == "partitioned" and sys.version_info < (3, 14): | |
dict.__setitem__(current_morsel, lower_key, True) |
This actually makes pickled cookies contain attribute not supported in standard http.cookie. Pickled cookiejars are not able to be unpickled if they contain partitioned cookies.
To Reproduce
from aiohttp import CookieJar
cj = CookieJar()
cj.update_cookies_from_headers(["a=a; Partitioned"], response_url=URL("http://example.com/"))
cj.save("cookies.bin")
CookieJar().load("cookies.bin")
File "D:\Program Files\Python311\Lib\site-packages\aiohttp\cookiejar.py", line 133, in load
self._cookies = pickle.load(f)
^^^^^^^^^^^^^^
File "D:\Program Files\Python311\Lib\http\cookies.py", line 312, in __setitem__
raise CookieError("Invalid attribute %r" % (K,))
http.cookies.CookieError: Invalid attribute 'partitioned'
Python Version
<=3.13
aiohttp Version
>=3.12.7