Skip to content

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

Closed

Description

@ezio-melotti
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']

    Activity

    1. ezio-melotti commented on Oct 24, 2011

      @ezio-melotti
      MemberAuthor
      $ 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.

    2. merwok commented on Oct 27, 2011

      @merwok
      Member

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

    3. ezio-melotti commented on Oct 27, 2011

      @ezio-melotti
      MemberAuthor

      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.

    4. klimov commented on Sep 15, 2015

      klimovmannequin
      Mannequin

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

    5. klimov commented on Sep 23, 2015

      klimovmannequin
      Mannequin

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

    6. ezio-melotti commented on Jan 1, 2016

      @ezio-melotti
      MemberAuthor

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

    7. transferred this issue fromon Apr 10, 2022
    Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

    Metadata

    Metadata

    Assignees

    No one assigned

      Labels

      topic-2to3type-bugAn unexpected behavior, bug, or error

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions