Visitar URL original
gh-112144: Make `http.cookiejar.CookieJar` picklable by XuehaiPan · Pull Request #112178 · python/cpython · GitHub
The Wayback Machine - https://web.archive.org/web/20251205000651/https://github.com/python/cpython/pull/112178
Skip to content

Conversation

@XuehaiPan
Copy link
Contributor

@XuehaiPan XuehaiPan commented Nov 16, 2023 •

This PR adds __getstate__ and __setstate__ methods to http.cookiejar.CookieJar to make it picklable. The __getstate__ method gets all attributes of the CookieJar object except the RLock.

Resolves #112144

@terryjreedy terryjreedy added the type-feature A feature request or enhancement label Nov 17, 2023
Copy link
Member

@terryjreedy terryjreedy left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know anything about why this lock is present and whether anything needs doing when unpickling; I leave that to another reviewer.

This new feature should have a test_pickle added to test/test_http_cookiejar.py. Since there is no CookiejarTest class, FileCookieJar seems like the most likely place for it. At least check that round-tripping, unpickle(pickle(jar)) == jar, with any needed adjustment for the lock entry, works as expected.

@bedevere-app
Copy link

bedevere-app bot commented Nov 17, 2023

A Python core developer has requested some changes be made to your pull request before we can consider merging it. If you could please address their requests along with any other requests in other reviews from core developers that would be appreciated.

Once you have made the requested changes, please leave a comment on this pull request containing the phrase I have made the requested changes; please review again. I will then notify any core developers who have left a review that you're ready for them to take another look at this pull request.

@XuehaiPan
Copy link
Contributor Author

I have made the requested changes; please review again

@XuehaiPan XuehaiPan changed the title gh-112144: Make http.cookiejar.CookieJar pickable gh-112144: Make http.cookiejar.CookieJar pickleable Dec 28, 2023
@XuehaiPan XuehaiPan changed the title gh-112144: Make http.cookiejar.CookieJar pickleable gh-112144: Make http.cookiejar.CookieJar picklable Dec 28, 2023
@XuehaiPan XuehaiPan closed this Jan 1, 2024
@XuehaiPan XuehaiPan deleted the cookiejar-picklable branch January 1, 2024 09:27
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting changes type-feature A feature request or enhancement

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Make http.cookiejar.CookieJar picklable

2 participants