2to3 question about fix_imports.

The fix_imports fix seems to fix only the first import per line that you have. So if you do for example import urllib2, cStringIO it will not fix cStringIO. Is this a bug or a feature? :-) If it's a feature it should warn at least, right? -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64

Le Friday 12 December 2008 17:39:33 Lennart Regebro, vous avez écrit :
The fix_imports fix seems to fix only the first import per line that you have. So if you do for example import urllib2, cStringIO it will not fix cStringIO.
Is this a bug or a feature? :-)
I prefer to see that as a bug and so replace cStringIO by StringIO. So can you open an issue? -- Victor Stinner aka haypo http://www.haypocalc.com/blog/

On Fri, Dec 12, 2008 at 11:39 AM, Lennart Regebro <regebro@gmail.com> wrote:
The fix_imports fix seems to fix only the first import per line that you have. So if you do for example import urllib2, cStringIO it will not fix cStringIO.
Is this a bug or a feature? :-) If it's a feature it should warn at least, right?
Which revision of python are you using? I tried the test-case you gave and 2to3 translated it perfectly. -- Alexandre alex@helios:~$ cat test.py import urllib2, cStringIO s = cStringIO.StringIO(urllib2.randombytes(100)) alex@helios:~$ 2to3 test.py RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma --- test.py (original) +++ test.py (refactored) @@ -1,3 +1,3 @@ -import urllib2, cStringIO +import urllib.request, urllib.error, io -s = cStringIO.StringIO(urllib2.randombytes(100)) +s = io.StringIO(urllib2.randombytes(100)) RefactoringTool: Files that need to be modified: RefactoringTool: test.py

On Sun, Dec 14, 2008 at 19:19, Alexandre Vassalotti <alexandre@peadrop.com> wrote:
Which revision of python are you using? I tried the test-case you gave and 2to3 translated it perfectly.
3.0, I haven't tried with trunk yet, and possibly it's a more complicated usecase. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64

On Sun, Dec 14, 2008 at 1:34 PM, Lennart Regebro <regebro@gmail.com> wrote:
On Sun, Dec 14, 2008 at 19:19, Alexandre Vassalotti <alexandre@peadrop.com> wrote:
Which revision of python are you using? I tried the test-case you gave and 2to3 translated it perfectly.
3.0, I haven't tried with trunk yet, and possibly it's a more complicated usecase.
Strange, fix_imports in Python 3.0 (final) looks fine. If you can come up with a reproducible example, please open a bug on bugs.python.org and set me as the assignee (my user id is alexandre.vassalotti). Thanks, -- Alexandre

On Sun, Dec 14, 2008 at 19:49, Alexandre Vassalotti <alexandre@peadrop.com> wrote:
3.0, I haven't tried with trunk yet, and possibly it's a more complicated usecase.
Strange, fix_imports in Python 3.0 (final) looks fine. If you can come up with a reproducible example, please open a bug on bugs.python.org and set me as the assignee (my user id is alexandre.vassalotti).
Actually, it wasn't more complex, but it was completely different. It doesn't have anything with the amount of statements, but it's specifically if you have urlparse in the imports that breaks it. I'll open a bug report. -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64

On Sun, Dec 14, 2008 at 20:02, Lennart Regebro <regebro@gmail.com> wrote:
On Sun, Dec 14, 2008 at 19:49, Alexandre Vassalotti <alexandre@peadrop.com> wrote:
3.0, I haven't tried with trunk yet, and possibly it's a more complicated usecase.
Strange, fix_imports in Python 3.0 (final) looks fine. If you can come up with a reproducible example, please open a bug on bugs.python.org and set me as the assignee (my user id is alexandre.vassalotti).
Actually, it wasn't more complex, but it was completely different. It doesn't have anything with the amount of statements, but it's specifically if you have urlparse in the imports that breaks it. I'll open a bug report.
I couldn't assign it to you, so here goes: http://bugs.python.org/issue4664 -- Lennart Regebro: Zope and Plone consulting. http://www.colliberty.com/ +33 661 58 14 64
participants (3)
-
Alexandre Vassalotti
-
Lennart Regebro
-
Victor Stinner