Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

2to3 fix_renames renames sys.maxint only in imports #57462

Closed
ezio-melotti opened this issue Oct 24, 2011 · 6 comments
Closed

2to3 fix_renames renames sys.maxint only in imports #57462

ezio-melotti opened this issue Oct 24, 2011 · 6 comments
Labels
topic-2to3 type-bug An unexpected behavior, bug, or error

Comments

@ezio-melotti
Copy link
Member

BPO 13253
Nosy @benjaminp, @ezio-melotti, @merwok, @meadori
Superseder
  • bpo-45544: Close 2to3 issues and list them here
  • Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.

    Show more details

    GitHub fields:

    assignee = None
    closed_at = <Date 2021-10-20.22:46:55.157>
    created_at = <Date 2011-10-24.06:25:52.221>
    labels = ['type-bug', 'expert-2to3']
    title = '2to3 fix_renames renames sys.maxint only in imports'
    updated_at = <Date 2021-10-20.22:46:55.156>
    user = 'https://github.com/ezio-melotti'

    bugs.python.org fields:

    activity = <Date 2021-10-20.22:46:55.156>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.22:46:55.157>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2011-10-24.06:25:52.221>
    creator = 'ezio.melotti'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 13253
    keywords = []
    message_count = 6.0
    messages = ['146278', '146493', '146495', '250802', '251460', '257275']
    nosy_count = 5.0
    nosy_names = ['benjamin.peterson', 'ezio.melotti', 'eric.araujo', 'meador.inge', 'klimov']
    pr_nums = []
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'behavior'
    url = 'https://bugs.python.org/issue13253'
    versions = ['Python 2.7', 'Python 3.5', 'Python 3.6']

    @ezio-melotti
    Copy link
    Member Author

    $ 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.

    @ezio-melotti ezio-melotti added topic-2to3 type-bug An unexpected behavior, bug, or error labels Oct 24, 2011
    @merwok
    Copy link
    Member

    merwok commented Oct 27, 2011

    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 :)

    @ezio-melotti
    Copy link
    Member Author

    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 bpo-13272.

    @klimov
    Copy link
    Mannequin

    klimov mannequin commented Sep 15, 2015

    I'm interesting to research this.
    I can show results by 23 September, I think.

    @klimov
    Copy link
    Mannequin

    klimov mannequin commented Sep 23, 2015

    I'm close to solution, but I need another 1 week.

    @ezio-melotti
    Copy link
    Member Author

    Nikita, did you manage to find a solution?
    If not, do you have a patch (even if not complete) to share?

    @ezio-melotti ezio-melotti transferred this issue from another repository Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
    Labels
    topic-2to3 type-bug An unexpected behavior, bug, or error
    Projects
    None yet
    Development

    No branches or pull requests

    3 participants