This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: 2to3 wont convert Cookie.Cookie properly
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.4
process
Status: closed Resolution: wont fix
Dependencies: Superseder: Close 2to3 issues and list them here
View: 45544
Assigned To: benjamin.peterson Nosy List: aldwinaldwin, benjamin.peterson, meador.inge, orsenthil
Priority: normal Keywords: patch

Created on 2009-04-02 03:22 by orsenthil, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 15268 closed aldwinaldwin, 2019-08-14 07:30
Messages (5)
msg85151 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2009-04-02 03:22
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.
msg85264 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2009-04-02 20:31
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.
msg98615 - (view) Author: Meador Inge (meador.inge) * (Python committer) Date: 2010-01-31 14:59
There is already a fixer for this in 'Lib/lib2to3/fixes/fix_imports.py'.  It was merged to the trunk in r64286.
msg190054 - (view) Author: Mark Lawrence (BreamoreBoy) * Date: 2013-05-26 03:36
I'm assuming msg98615 is correct so this can be closed.
msg190175 - (view) Author: Senthil Kumaran (orsenthil) * (Python committer) Date: 2013-05-28 05:39
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.]
History
Date User Action Args
2022-04-11 14:56:47adminsetgithub: 49914
2021-10-20 22:57:25iritkatrielsetstatus: open -> closed
superseder: Close 2to3 issues and list them here
resolution: wont fix
stage: patch review -> resolved
2019-08-14 07:33:17aldwinaldwinsetnosy: + aldwinaldwin
2019-08-14 07:30:48aldwinaldwinsetkeywords: + patch
stage: patch review
pull_requests: + pull_request14990
2014-02-03 17:09:51BreamoreBoysetnosy: - BreamoreBoy
2013-05-28 05:39:54orsenthilsetmessages: + msg190175
versions: + Python 3.4, - Python 3.1
2013-05-26 03:36:35BreamoreBoysetnosy: + BreamoreBoy
messages: + msg190054
2010-01-31 14:59:21meador.ingesetnosy: + meador.inge
messages: + msg98615
2009-04-02 20:31:30benjamin.petersonsetmessages: + msg85264
2009-04-02 03:22:47orsenthilcreate