Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Recommendation re: recent addition to connectivity.py to address partitioned cookies #728

Open
danielbrunt57 opened this issue Sep 14, 2024 · 1 comment

Comments

@danielbrunt57
Copy link

danielbrunt57 commented Sep 14, 2024

I saw your fix for the partitioned cookie error in python 3.12 cookies.py and have implemented a variation of this into the alexapy python package thus resolving a 3 month old issue.
Your code is version restricted though and I believe the partitioned "key : value" pair isn't going to make it into Python 3.13 cookies.py Morsel class which would then break your code again.
My variation is version non-specific and uses _reserved.update which only adds the "key : value" pair if it does not exist and does nothing if it's already there. The _flags.add already behaves that way so it's fine.
alexalogin.py:

`from http.cookies import Morsel, SimpleCookie`
"""Ensure cookies.Morsel contains "partitioned"
   See: https://github.com/python/cpython/issues/112713
"""
partitioned = { "partitioned" : "Partitioned" }
Morsel._reserved.update(partitioned)
Morsel._flags.add("partitioned")
_LOGGER.debug("http.cookies patch: Morsel._reserved: %s; Morsel._flags: %s", partitioned, Morsel._flags)

I had to alter my implementation of your code as alexalogin.py was already using a variable named cookies thus preventing me from importing cookies from http.

@Kane610
Copy link
Owner

Kane610 commented Sep 18, 2024

Thanks! All kudos goes to ep1cman in uilibs/uiprotect#36 that I took the changes from.

I'll wait some before I do this change

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants