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 fix_renames renames sys.maxint only in imports
Type: behavior Stage: resolved
Components: 2to3 (2.x to 3.x conversion tool) Versions: Python 3.6, Python 3.5, Python 2.7
process
Status: closed Resolution: wont fix
Dependencies: Superseder: Close 2to3 issues and list them here
View: 45544
Assigned To: Nosy List: benjamin.peterson, eric.araujo, ezio.melotti, klimov, meador.inge
Priority: normal Keywords:

Created on 2011-10-24 06:25 by ezio.melotti, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (6)
msg146278 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-24 06:25
$ cat deleteme.py 
from sys import maxint
print 'maxint', maxint
$ 2to3 deleteme.py 
RefactoringTool: Skipping implicit fixer: buffer
RefactoringTool: Skipping implicit fixer: idioms
RefactoringTool: Skipping implicit fixer: set_literal
RefactoringTool: Skipping implicit fixer: ws_comma
RefactoringTool: Refactored deleteme.py
--- deleteme.py (original)
+++ deleteme.py (refactored)
@@ -1,2 +1,2 @@
-from sys import maxint
-print 'maxint', maxint
+from sys import maxsize
+print('maxint', maxint)
RefactoringTool: Files that need to be modified:
RefactoringTool: deleteme.py

The maxint in the print should be converted too.
msg146493 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2011-10-27 15:37
Do people really import maxint from sys?  I’d find that less readable than using sys.maxint —which should, if you ask me, also be replaced :)
msg146495 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2011-10-27 15:44
I do (or at least did it in at least one place :).
I think the problem is actually more general, and I don't know if it's by design.
If a name in the import is changed, all the other occurrences of the name should be changed as well.  I don't know if 2to3 is powerful enough to recognize what occurrences should be left untouched (e.g. if I also have maxsize = 100 inside a function), and how difficult would it be to do it.
See also #13272.
msg250802 - (view) Author: Nikita Klimov (klimov) Date: 2015-09-15 20:16
I'm interesting to research this. 
I can show results by 23 September, I think.
msg251460 - (view) Author: Nikita Klimov (klimov) Date: 2015-09-23 21:36
I'm close to solution, but I need another 1 week.
msg257275 - (view) Author: Ezio Melotti (ezio.melotti) * (Python committer) Date: 2016-01-01 05:29
Nikita, did you manage to find a solution?
If not, do you have a patch (even if not complete) to share?
History
Date User Action Args
2022-04-11 14:57:23adminsetgithub: 57462
2021-10-20 22:46:55iritkatrielsetstatus: open -> closed
superseder: Close 2to3 issues and list them here
resolution: wont fix
stage: needs patch -> resolved
2016-01-01 05:29:28ezio.melottisetmessages: + msg257275
versions: - Python 3.2, Python 3.3, Python 3.4
2015-09-23 21:36:24klimovsetmessages: + msg251460
2015-09-15 20:16:52klimovsetnosy: + klimov

messages: + msg250802
versions: + Python 3.4, Python 3.5, Python 3.6
2011-10-27 15:44:52ezio.melottisetmessages: + msg146495
2011-10-27 15:37:48eric.araujosetnosy: + eric.araujo
messages: + msg146493
2011-10-27 14:14:21meador.ingesetnosy: + meador.inge
2011-10-24 06:25:52ezio.melotticreate