[New-bugs-announce] [issue7861] 2to3: "import foo" -> "from . import foo"

Thomas Spura report at bugs.python.org
Fri Feb 5 20:37:32 CET 2010


New submission from Thomas Spura <tomspur at fedoraproject.org>:

My custom setup / testcase for testing the transition "import foo" -> "from . import foo":

mkdir -p test/sub
touch test/sub/__init__.py
touch test/__init__.py

cat >> test/__init__.py << EOF
import sub
EOF

cat >> test.py << EOF
import test
EOF

This won't work with python3 so I ran 2to3 on it:
$ 2to3 .
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: No files need to be modified.

-> Nothing found.

Using the python3 version of 2to3:
$ python3-2to3 .
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored ./test/__init__.py
--- ./test/__init__.py (original)
+++ ./test/__init__.py (refactored)
@@ -1,1 +1,1 @@
-import sub
+from . import sub
RefactoringTool: Files that need to be modified:
RefactoringTool: ./test/__init__.py


-> python3 version of 2to3 can change it, but Python 2.6.2 is not able to.

----------
components: 2to3 (2.x to 3.0 conversion tool)
messages: 98900
nosy: tomspur
severity: normal
status: open
title: 2to3: "import foo" ->  "from . import foo"
type: compile error
versions: Python 2.6

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue7861>
_______________________________________


More information about the New-bugs-announce mailing list