Title: LWPCookieJar.save() gives unexpected results in 3.11.0 · Issue #99576 · python/cpython · GitHub
Open Graph Title: LWPCookieJar.save() gives unexpected results in 3.11.0 · Issue #99576 · python/cpython
X Title: LWPCookieJar.save() gives unexpected results in 3.11.0 · Issue #99576 · python/cpython
Description: Bug report LWPCookieJar.save() doesn't truncate the file. So removing cookies from an existing jar file then saving it gives unexpected results : from http.cookiejar import LWPCookieJar from urllib.request import Request, urlopen lwp = L...
Open Graph Description: Bug report LWPCookieJar.save() doesn't truncate the file. So removing cookies from an existing jar file then saving it gives unexpected results : from http.cookiejar import LWPCookieJar from urllib...
X Description: Bug report LWPCookieJar.save() doesn't truncate the file. So removing cookies from an existing jar file then saving it gives unexpected results : from http.cookiejar import LWPCookieJar from ur...
Opengraph URL: https://github.com/python/cpython/issues/99576
X: @github
Domain: github.com
{"@context":"https://schema.org","@type":"DiscussionForumPosting","headline":"LWPCookieJar.save() gives unexpected results in 3.11.0","articleBody":"# Bug report\r\n\r\n`LWPCookieJar.save()` doesn't truncate the file.\r\nSo removing cookies from an existing jar file then saving it gives unexpected results : \r\n```python3\r\nfrom http.cookiejar import LWPCookieJar\r\nfrom urllib.request import Request, urlopen\r\n\r\nlwp = LWPCookieJar(\"cookies.lwp\")\r\n\r\n# get some cookies \u0026 save\r\nrequest = Request(\"https://www.scoopmeacookie.com/give-me-more/\")\r\nwith urlopen(request) as response:\r\n lwp.extract_cookies(response, request)\r\n# here's some cookies\r\nprint(f\"Extracted : {lwp}\")\r\nlwp.save()\r\n\r\n# clear the jar \u0026 save\r\nlwp.clear()\r\n# the jar is now empty\r\nprint(f\"Clear : {lwp}\")\r\nlwp.save()\r\n\r\n# are those cookies really gone ?\r\nlwp.load()\r\n# they're back ! that would be great IRL\r\n# LWPCookieJar.save() didn't truncate the file (os.O_TRUNC is missing)\r\nprint(f\"Reload : {lwp}\")\r\n```\r\n\r\n# Environment\r\n\r\n- Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]\r\n- Windows 10 64 bits 22H2\r\n\r\n\n\n\u003c!-- gh-linked-prs --\u003e\n### Linked PRs\n* gh-99616\n* gh-100377\n\u003c!-- /gh-linked-prs --\u003e\n","author":{"url":"https://github.com/sebdelsol","@type":"Person","name":"sebdelsol"},"datePublished":"2022-11-18T13:08:22.000Z","interactionStatistic":{"@type":"InteractionCounter","interactionType":"https://schema.org/CommentAction","userInteractionCount":2},"url":"https://github.com/99576/cpython/issues/99576"}
| route-pattern | /_view_fragments/issues/show/:user_id/:repository/:id/issue_layout(.:format) |
| route-controller | voltron_issues_fragments |
| route-action | issue_layout |
| fetch-nonce | v2:6b02ac03-77aa-c316-0aba-c0afb97b9c4a |
| current-catalog-service-hash | 81bb79d38c15960b92d99bca9288a9108c7a47b18f2423d0f6438c5b7bcd2114 |
| request-id | E6BC:215DE9:B2530B:F7DE29:6968DAD4 |
| html-safe-nonce | 9213eb5d737a71908af5236c59d3dca3c9ea2de59f9500002057ec6f009513ab |
| visitor-payload | eyJyZWZlcnJlciI6IiIsInJlcXVlc3RfaWQiOiJFNkJDOjIxNURFOTpCMjUzMEI6RjdERTI5OjY5NjhEQUQ0IiwidmlzaXRvcl9pZCI6IjE2NDM5OTg1MTA2OTc3MzI4MjAiLCJyZWdpb25fZWRnZSI6ImlhZCIsInJlZ2lvbl9yZW5kZXIiOiJpYWQifQ== |
| visitor-hmac | 3288aa834864b48ecbd416a1f26414f54aee76fc7fcf64e0ab44c196296114f8 |
| hovercard-subject-tag | issue:1455093221 |
| github-keyboard-shortcuts | repository,issues,copilot |
| google-site-verification | Apib7-x98H0j5cPqHWwSMm6dNU4GmODRoqxLiDzdx9I |
| octolytics-url | https://collector.github.com/github/collect |
| analytics-location | / |
| fb:app_id | 1401488693436528 |
| apple-itunes-app | app-id=1477376905, app-argument=https://github.com/_view_fragments/issues/show/python/cpython/99576/issue_layout |
| twitter:image | https://opengraph.githubassets.com/de2e9713ee17ec5b48183ae54efa2e9c69712c6f23a99a17721a09a18cb764a7/python/cpython/issues/99576 |
| twitter:card | summary_large_image |
| og:image | https://opengraph.githubassets.com/de2e9713ee17ec5b48183ae54efa2e9c69712c6f23a99a17721a09a18cb764a7/python/cpython/issues/99576 |
| og:image:alt | Bug report LWPCookieJar.save() doesn't truncate the file. So removing cookies from an existing jar file then saving it gives unexpected results : from http.cookiejar import LWPCookieJar from urllib... |
| og:image:width | 1200 |
| og:image:height | 600 |
| og:site_name | GitHub |
| og:type | object |
| og:author:username | sebdelsol |
| hostname | github.com |
| expected-hostname | github.com |
| None | 3c4e9f2fc1db52c609205138be6a397cfde4574cb54d53015014de30dd49f27e |
| turbo-cache-control | no-preview |
| go-import | github.com/python/cpython git https://github.com/python/cpython.git |
| octolytics-dimension-user_id | 1525981 |
| octolytics-dimension-user_login | python |
| octolytics-dimension-repository_id | 81598961 |
| octolytics-dimension-repository_nwo | python/cpython |
| octolytics-dimension-repository_public | true |
| octolytics-dimension-repository_is_fork | false |
| octolytics-dimension-repository_network_root_id | 81598961 |
| octolytics-dimension-repository_network_root_nwo | python/cpython |
| turbo-body-classes | logged-out env-production page-responsive |
| disable-turbo | false |
| browser-stats-url | https://api.github.com/_private/browser/stats |
| browser-errors-url | https://api.github.com/_private/browser/errors |
| release | 1fb1ea11f8c37dd4dd50347cca70d89824e93788 |
| ui-target | full |
| theme-color | #1e2327 |
| color-scheme | light dark |
Links:
Viewport: width=device-width