Issue 3259: fix_imports needs to be using the 'as' keyword (original) (raw)
Issue3259
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.
This issue has been migrated to GitHub: https://github.com/python/cpython/issues/47509
classification
Title: | fix_imports needs to be using the 'as' keyword | |
---|---|---|
Type: | Stage: | |
Components: | 2to3 (2.x to 3.x conversion tool) | Versions: |
process
Status: | closed | Resolution: | not a bug |
---|---|---|---|
Dependencies: | Superseder: | ||
Assigned To: | collinwinter | Nosy List: | benjamin.peterson, brett.cannon, collinwinter |
Priority: | critical | Keywords: |
Created on 2008-07-02 19:54 by brett.cannon, last changed 2022-04-11 14:56 by admin. This issue is now closed.
Messages (3) | ||
---|---|---|
msg69113 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2008-07-02 19:54 |
If you run ``echo "import commands" | ./2to3 -f imports -``, you end up with ``import subprocess``. That's bad as the code in the module works off of 'commands'. The fix really should be ``import subprocess as commands``. | ||
msg69161 - (view) | Author: Benjamin Peterson (benjamin.peterson) * ![]() |
Date: 2008-07-03 02:37 |
Yeah, but then commands will be replaced with subprocess. $ cat > m import commands commands.getoutput() $ 2to3 m RefactoringTool: Skipping implicit fixer: buffer RefactoringTool: Skipping implicit fixer: idioms RefactoringTool: Skipping implicit fixer: ws_comma --- m (original) +++ m (refactored) @@ -1,2 +1,2 @@ -import commands -commands.getoutput() +import subprocess +subprocess.getoutput() | ||
msg69163 - (view) | Author: Brett Cannon (brett.cannon) * ![]() |
Date: 2008-07-03 05:11 |
Gotcha. Here is to hoping that won't cause issues with someone's variable name being silly. |
History | |||
---|---|---|---|
Date | User | Action | Args |
2022-04-11 14:56:36 | admin | set | github: 47509 |
2008-07-03 05:13:47 | brett.cannon | set | resolution: not a bug |
2008-07-03 05:11:59 | brett.cannon | set | status: open -> closedmessages: + |
2008-07-03 02:37:32 | benjamin.peterson | set | nosy: + benjamin.petersonmessages: + |
2008-07-02 19:54:07 | brett.cannon | create |