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 does not fix zip in some cases #65827

Closed
RobertG mannequin opened this issue Jun 1, 2014 · 3 comments
Closed

2to3 does not fix zip in some cases #65827

RobertG mannequin opened this issue Jun 1, 2014 · 3 comments

Comments

@RobertG
Copy link
Mannequin

RobertG mannequin commented Jun 1, 2014

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']

    @RobertG
    Copy link
    Mannequin Author

    RobertG mannequin commented Jun 1, 2014

    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.

    @RobertG RobertG mannequin added the topic-2to3 label Jun 1, 2014
    @berkerpeksag
    Copy link
    Member

    This is a duplicate of bpo-20742.

    @stuarteberg
    Copy link
    Mannequin

    stuarteberg mannequin commented Jan 19, 2017

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

    @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
    Projects
    None yet
    Development

    No branches or pull requests

    1 participant