classification
Title: 2to3 mishandles StringIO inside a package with an io.py module
Type: Stage:
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 2.6
process
Status: closed Resolution: out of date
Dependencies: Superseder:
Assigned To: Nosy List: Robert.Kern, benjamin.peterson
Priority: normal Keywords:

Created on 2010-03-24 15:06 by Robert.Kern, last changed 2010-03-24 20:42 by benjamin.peterson. This issue is now closed.

Messages (2)
msg101636 - (view) Author: Robert Kern (Robert.Kern) Date: 2010-03-24 15:06
When a module inside a package imports StringIO from cStringIO, it should change that to "from io import StringIO". However, if there is a module inside the package named io.py, 2to3 changes it to "from .io import StringIO".

[bug23]$ tree
.
`-- package
    |-- __init__.py
    |-- helper.py
    `-- io.py

1 directory, 3 files

[bug23]$ cat package/helper.py
from cStringIO import StringIO

[bug23]$ 2to3 package         
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
--- package/helper.py (original)
+++ package/helper.py (refactored)
@@ -1,1 +1,1 @@
-from cStringIO import StringIO
+from .io import StringIO
RefactoringTool: Files that need to be modified:
RefactoringTool: package/helper.py
msg101653 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-03-24 20:42
This should be fixed in the latest versions of 2to3.
History
Date User Action Args
2010-03-24 20:42:36benjamin.petersonsetstatus: open -> closed

nosy: + benjamin.peterson
messages: + msg101653

resolution: out of date
2010-03-24 15:06:17Robert.Kerncreate