msg77815 - (view) |
Author: Lennart Regebro (lregebro) |
Date: 2008-12-14 19:07 |
If you have urlparse before cStringIO in an import line, 2to3 will not convert the cStringIO to io. However, reverse the order, and urlparse will not get translated. So this file: import urlparse, cStringIO import cStringIO, urlparse will with 2to3 return the following diff: --- test3.py (original) +++ test3.py (refactored) @@ -1,3 +1,3 @@ -import urlparse, cStringIO -import cStringIO, urlparse +import urllib.parse, cStringIO +import io, urlparse |
|
|
msg77816 - (view) |
Author: Alexandre Vassalotti (alexandre.vassalotti) *  |
Date: 2008-12-14 19:20 |
Sorry, I still cannot reproduce it. Could you attach your test file? Maybe it is some weird encoding bug. alex@helios:~$ 2to3 -f imports test.py --- test.py (original) +++ test.py (refactored) @@ -1,2 +1,2 @@ -import urlparse, cStringIO -import cStringIO, urlparse +import urllib.parse, io +import io, urllib.parse RefactoringTool: Files that need to be modified: RefactoringTool: test.py |
|
|
msg77819 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2008-12-14 19:50 |
Here's one which doesn't work correctly: $ 2to3 - RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: set_literal RefactoringTool: Skipping implicit fixer: ws_comma import cStringIO, HTMLParser --- (original) +++ (refactored) @@ -1,1 +1,1 @@ -import cStringIO, HTMLParser +import io, HTMLParser RefactoringTool: Files that need to be modified: RefactoringTool: This is because the fix_imports pattern catching one module per import statement. |
|
|
msg77824 - (view) |
Author: Lennart Regebro (lregebro) |
Date: 2008-12-14 20:54 |
Heres my test file. |
|
|
msg77825 - (view) |
Author: Alexandre Vassalotti (alexandre.vassalotti) *  |
Date: 2008-12-14 21:06 |
Benjamin, your example fails for a different reason--i.e. the fixer for HTMLParser is missing. Sorry Lennart, I still cannot reproduce it. |
|
|
msg77827 - (view) |
Author: Lennart Regebro (lregebro) |
Date: 2008-12-14 21:11 |
What version are you running? Can you post the output? |
|
|
msg77831 - (view) |
Author: Alexandre Vassalotti (alexandre.vassalotti) *  |
Date: 2008-12-14 21:22 |
I got it. It is a regression from a previous version of 2to3's fix_imports. I was able to reproduce your problem using the sandbox's 2to3. And to answer your question, I still running an older RC release of Python 3.0. That explains why I couldn't reproduce the problem. $ python3.0 -c "import sys; print(sys.version)" 3.0rc2+ (py3k:67237, Nov 16 2008, 15:10:03) [GCC 4.2.4 (Ubuntu 4.2.4-1ubuntu3)] |
|
|
msg77839 - (view) |
Author: Benjamin Peterson (benjamin.peterson) *  |
Date: 2008-12-14 21:55 |
Fixed in r67774. |
|
|