GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — LWPCookieJar.save() gives unexpected results in 3.11.0 · Issue #99576 · python/cpython

LWPCookieJar.save() gives unexpected results in 3.11.0 #99576

New issue
Copy link
New issue
Copy link
Closed
Closed
LWPCookieJar.save() gives unexpected results in 3.11.0#99576
Copy link
Labels
type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

Description

@sebdelsol
sebdelsol
opened on Nov 18, 2022
Issue body actions

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 = LWPCookieJar("cookies.lwp")

# get some cookies & save
request = Request("https://www.scoopmeacookie.com/give-me-more/")
with urlopen(request) as response:
    lwp.extract_cookies(response, request)
# here's some cookies
print(f"Extracted : {lwp}")
lwp.save()

# clear the jar & save
lwp.clear()
# the jar is now empty
print(f"Clear     : {lwp}")
lwp.save()

# are those cookies really gone ?
lwp.load()
# they're back ! that would be great IRL
# LWPCookieJar.save() didn't truncate the file (os.O_TRUNC is missing)
print(f"Reload    : {lwp}")

Environment

  • Python 3.11.0 (main, Oct 24 2022, 18:26:48) [MSC v.1933 64 bit (AMD64)]
  • Windows 10 64 bits 22H2

Linked PRs

  • gh-99576: Fix cookiejar file that was not truncated for some classes #99616
  • [3.11] gh-99576: Fix cookiejar file that was not truncated for some classes (GH-99616) #100377

Activity

  1. sebdelsol
    added
    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error
    on Nov 18, 2022
  2. sebdelsol
    changed the title [-]LWPCookieJar.save() doesn't truncate the file in 3.11.0[/-] [+]LWPCookieJar.save() gives unexpected results in 3.11.0[/+] on Nov 18, 2022
  3. sobolevn
    added a commit that references this issue on Nov 20, 2022

    pythongh-99576: Fix cookiejar file that was not truncated for some cl…

    26ab026
  4. ambv
    added a commit that references this issue on Dec 20, 2022

    gh-99576: Fix cookiejar file that was not truncated for some classes (G…

    44892d4
  5. miss-islington
    added a commit that references this issue on Dec 20, 2022

    pythongh-99576: Fix cookiejar file that was not truncated for some cl…

    73dbf27
  6. ambv
    added a commit that references this issue on Dec 20, 2022

    [3.11] gh-99576: Fix cookiejar file that was not truncated for some c…

    73d2b15
  7. ambv commented on Dec 20, 2022

    @ambv
    ambv
    on Dec 20, 2022
    Contributor
    More actions

    Fixed for release in 3.11.2 and 3.12.0.

  8. ambv
    closed this as completedon Dec 20, 2022
  9. ambv commented on Dec 20, 2022

    @ambv
    ambv
    on Dec 20, 2022
    Contributor
    More actions

    Thanks for the fix, @sobolevn! ✨ 🍰 ✨

  10. iritkatriel
    added a commit that references this issue on Dec 28, 2022

    Merged main into regmachine branch (#50)

    fdc73cb
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    type-bugAn unexpected behavior, bug, or errorAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions

      You are visitor 01402503 — GeezerVison does not store the pages you look up.
      Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.