Skip to content

2to3 does not fix zip in some cases #65827

Closed

Description

@RobertG
mannequin
BPO 21628
Nosy @benjaminp, @berkerpeksag, @stuarteberg
Superseder
  • bpo-20742: 2to3 zip fixer doesn't fix for loops.
  • 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 2014-06-02.11:15:08.742>
    created_at = <Date 2014-06-01.17:27:53.399>
    labels = ['expert-2to3']
    title = '2to3 does not fix zip in some cases'
    updated_at = <Date 2017-01-19.14:45:23.578>
    user = 'https://bugs.python.org/RobertG'

    bugs.python.org fields:

    activity = <Date 2017-01-19.14:45:23.578>
    actor = 'stuarteberg'
    assignee = 'none'
    closed = True
    closed_date = <Date 2014-06-02.11:15:08.742>
    closer = 'berker.peksag'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2014-06-01.17:27:53.399>
    creator = 'RobertG'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 21628
    keywords = []
    message_count = 3.0
    messages = ['219511', '219568', '285793']
    nosy_count = 4.0
    nosy_names = ['benjamin.peterson', 'berker.peksag', 'RobertG', 'stuarteberg']
    pr_nums = []
    priority = 'normal'
    resolution = 'duplicate'
    stage = 'resolved'
    status = 'closed'
    superseder = '20742'
    type = None
    url = 'https://bugs.python.org/issue21628'
    versions = ['Python 3.4']

    Activity

    1. RobertG commented on Jun 1, 2014

      RobertGmannequin
      MannequinAuthor

      Consider this program

      def foo(a,b):
      	return min(zip(a,b)[2])

      print foo(range(5), (0,9,-9))

      With the default options, 2to3 rewrites this as

      def foo(a,b):
      	return min(zip(a,b)[2])

      print(foo(list(range(5)), (0,9,-9)))

      For some reason, 2to3 fails to wrap the call to zip in a list, even though the 2to3 documentation says that there is a fixer which does this. Obviously, the generated code will not work in Python 3 since you can't subscript an iterator.

    2. berkerpeksag commented on Jun 2, 2014

      @berkerpeksag
      Member

      This is a duplicate of bpo-20742.

    3. stuarteberg commented on Jan 19, 2017

      stuartebergmannequin
      Mannequin

      Already closed, but FWIW, I think this was incorrectly marked as a duplicate. bpo-20742 discusses a different issue related to lib2to3 and zip.

      Meanwhile, this issue has been raised again in 28837, so I will continue the discussion there. (I have a patch.)

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