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: "import foo" -> "from . import foo"
Type: enhancement Stage: needs patch
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: benjamin.peterson, dmalcolm, ezio.melotti, mark.dickinson, tomspur, wolever
Priority: normal Keywords:

Created on 2010-02-05 19:37 by tomspur, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Messages (4)
msg98900 - (view) Author: Thomas Spura (tomspur) Date: 2010-02-05 19:37
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.
msg98903 - (view) Author: Thomas Spura (tomspur) Date: 2010-02-05 19:49
#2446 should be related to this one.
msg98929 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2010-02-06 02:09
Well, you'll just have to wait for the next version of 2.6 to be released then.
msg99067 - (view) Author: Thomas Spura (tomspur) Date: 2010-02-08 20:31
The commit I'm talking about was 22 months ago (r61755), python 2.6.2 was released April 14, 2009.

At least strange, that this is not jet in there, but if you think, it will in the next version...
History
Date User Action Args
2022-04-11 14:56:57adminsetgithub: 52109
2010-02-08 20:31:50tomspursetmessages: + msg99067
2010-02-06 02:09:17benjamin.petersonsetstatus: open -> closed
resolution: out of date
messages: + msg98929
2010-02-05 20:00:39dmalcolmsetnosy: + dmalcolm
2010-02-05 19:49:00tomspursetnosy: + wolever
messages: + msg98903
2010-02-05 19:41:04ezio.melottisetpriority: normal
nosy: + mark.dickinson, benjamin.peterson, ezio.melotti

type: compile error -> enhancement
stage: needs patch
2010-02-05 19:37:30tomspurcreate