Issue 11276: 2to3: imports fixer doesn't update references to modules specified without attributes - Python tracker

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
process
Status: closed Resolution: wont fix
Dependencies: Superseder: Close 2to3 issues and list them here
View: 45544
Assigned To: Nosy List: Arfrever, Claudiu.Popa, benjamin.peterson, eric.araujo, jaraco, vinay.sajip
Priority: normal Keywords:

Created on 2011-02-21 20:32 by Arfrever, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (7)
msg128991 - (view) Author: Arfrever Frehtes Taifersar Arahesis (Arfrever) * (Python triager) Date: 2011-02-21 20:32
$ cat test.py
import cPickle
cPickle
cPickle.load
$ 2to3 -f imports test.py
RefactoringTool: Refactored test.py
--- test.py     (original)
+++ test.py     (refactored)
@@ -1,3 +1,3 @@
-import cPickle
+import pickle
 cPickle
-cPickle.load
+pickle.load
RefactoringTool: Files that need to be modified:
RefactoringTool: test.py
msg129109 - (view) Author: Brett Cannon (brett.cannon) * (Python committer) Date: 2011-02-22 19:08
While directly referencing a module on its own is useless, this is an issue if the module is used in e.g., an assignment: ``blah = cPickle`` is not changed.
msg129236 - (view) Author: Benjamin Peterson (benjamin.peterson) * (Python committer) Date: 2011-02-24 01:28
I'm trying to remember if this was intentional or not...
msg130915 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2011-03-14 21:52
This bug affects distutils2. See #11502.
msg131032 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2011-03-15 19:59
This bug also affects poster. http://bitbucket.org/jaraco/poster (httplib reference in httpstreaming.py)
msg131042 - (view) Author: Jason R. Coombs (jaraco) * (Python committer) Date: 2011-03-15 21:37
it looks like lib maintainers can work around the limitation by using the syntax:

 import _winreg as winreg

And then reference the name winreg (or any other preferred name).
msg133924 - (view) Author: Vinay Sajip (vinay.sajip) * (Python committer) Date: 2011-04-17 13:38
Another example: when processing

if hasattr(httplib, 'ssl'):
    pass

It doesn't spot that httplib should be changed to http.client.