Skip to content

2to3 reports some files as both not changing and having been modified #85282

Closed

Description

@AWhetter
mannequin
BPO 41110
Nosy @benjaminp, @AWhetter
PRs
  • bpo-41110: Fixed lib2to3 reporting some unchanged files as needing modification #21296
  • 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:51:55.292>
    created_at = <Date 2020-06-25.04:46:55.584>
    labels = ['3.8', 'type-bug', 'expert-2to3', '3.9', '3.10']
    title = '2to3 reports some files as both not changing and having been modified'
    updated_at = <Date 2021-10-20.22:51:55.291>
    user = 'https://github.com/AWhetter'

    bugs.python.org fields:

    activity = <Date 2021-10-20.22:51:55.291>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.22:51:55.292>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2020-06-25.04:46:55.584>
    creator = 'AWhetter'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 41110
    keywords = ['patch']
    message_count = 1.0
    messages = ['372299']
    nosy_count = 2.0
    nosy_names = ['benjamin.peterson', 'AWhetter']
    pr_nums = ['21296']
    priority = 'normal'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'behavior'
    url = 'https://bugs.python.org/issue41110'
    versions = ['Python 3.8', 'Python 3.9', 'Python 3.10']

    Activity

    1. AWhetter commented on Jun 25, 2020

      AWhettermannequin
      MannequinAuthor

      Many of the fixers cause the tool to report a file as both unchanged and modified.

      For example when checking a file with the following contents:

      s = "str"
      

      using the following command: python -m lib2to3 -f unicode unicode_test.py
      The following is output:

      RefactoringTool: No changes to unicode_test.py
      RefactoringTool: Files that need to be modified:
      RefactoringTool: unicode_test.py
      

      When a fixer returns a node, even if it is the original node without changes, it is considered as a change to the code (

      if new is not None:
      node.replace(new)
      ) and the file is later added to the list of modified files. I have not yet identified which fixers have this issue.

      The fix appears to be that fixers need to be aware of when they have not made a change and should None when that is the case.

    2. added
      type-bugAn unexpected behavior, bug, or error
      and removed on Jul 3, 2020
    3. 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

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions