Skip to content

2to3 wont convert Cookie.Cookie properlyΒ #49914

Closed

Description

@orsenthil
BPO 5664
Nosy @orsenthil, @benjaminp, @meadori, @aldwinaldwin
PRs
  • bpo-5664: 2to3 convert Cookie.Cookie properlyΒ #15268
  • Superseder
  • bpo-45544: Close 2to3 issues and list them here
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = 'https://github.com/benjaminp'
    closed_at = <Date 2021-10-20.22:57:25.564>
    created_at = <Date 2009-04-02.03:22:46.992>
    labels = ['type-bug', 'expert-2to3']
    title = '2to3 wont convert Cookie.Cookie properly'
    updated_at = <Date 2021-10-20.22:57:25.564>
    user = 'https://github.com/orsenthil'

    bugs.python.org fields:

    activity = <Date 2021-10-20.22:57:25.564>
    actor = 'iritkatriel'
    assignee = 'benjamin.peterson'
    closed = True
    closed_date = <Date 2021-10-20.22:57:25.564>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2009-04-02.03:22:46.992>
    creator = 'orsenthil'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 5664
    keywords = ['patch']
    message_count = 5.0
    messages = ['85151', '85264', '98615', '190054', '190175']
    nosy_count = 4.0
    nosy_names = ['orsenthil', 'benjamin.peterson', 'meador.inge', 'aldwinaldwin']
    pr_nums = ['15268']
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'behavior'
    url = 'https://bugs.python.org/issue5664'
    versions = ['Python 3.4']

    Activity

    1. orsenthil commented on Apr 2, 2009

      @orsenthil
      MemberAuthor

      In 2.7 code have:
      import Cookie
      c = Cookie.Cookie('abc')

      2to3 would do:
      c = http.cookies.Cookie('abc')

      This is wrong as there is no class as Cookie in http.cookies. It should
      translated to be http.cookies.SimpleCookie.

    2. benjaminp commented on Apr 2, 2009

      @benjaminp
      Contributor

      2009/4/1 Senthil <report@bugs.python.org>:

      New submission from Senthil <orsenthil@gmail.com>:

      In 2.7 code have:
      import Cookie
      c = Cookie.Cookie('abc')

      2to3 would do:
      c = http.cookies.Cookie('abc')

      This is wrong as there is no class as Cookie in http.cookies. It should
      translated to be http.cookies.SimpleCookie.

      That's unfortunate. I suppose a new custom fixer will have to be
      written for Cookie now.

    3. meadori commented on Jan 31, 2010

      @meadori
      Member

      There is already a fixer for this in 'Lib/lib2to3/fixes/fix_imports.py'. It was merged to the trunk in r64286.

    4. BreamoreBoy commented on May 26, 2013

      BreamoreBoymannequin
      Mannequin

      I'm assuming msg98615 is correct so this can be closed.

    5. orsenthil commented on May 28, 2013

      @orsenthil
      MemberAuthor

      Not actually, It is still translating to http.cookies.Cookie - which does not exist.

      $ ./cpythonvenv/bin/2to3-3.4 bug-fixes/test1.py
      RefactoringTool: Refactored bug-fixes/test1.py
      --- bug-fixes/test1.py  (original)
      +++ bug-fixes/test1.py  (refactored)
      @@ -1,2 +1,2 @@
      -import Cookie
      -c = Cookie.Cookie('abc')
      +import http.cookies
      +c = http.cookies.Cookie('abc')

      BTW, Cookie.Cookie is a deprecated interface so there is a possibility that only small portion of the real world code which has not updated their Python stdlib idioms since (Python 2.2/Python2.4?) would see this bug manifested.

      [Note: Long-time users of Cookie.py will remember using
      Cookie.Cookie() to create an Cookie object. Although deprecated, it
      is still supported by the code. See the Backward Compatibility notes
      for more information.]

    6. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    Labels

    topic-2to3type-bugAn unexpected behavior, bug, or error

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions