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

itertools fixer fails #56822

Closed
VPeric mannequin opened this issue Jul 22, 2011 · 4 comments
Closed

itertools fixer fails #56822

VPeric mannequin opened this issue Jul 22, 2011 · 4 comments
Labels
topic-2to3 type-bug An unexpected behavior, bug, or error

Comments

@VPeric
Copy link
Mannequin

VPeric mannequin commented Jul 22, 2011

BPO 12613
Nosy @benjaminp, @merwok, @meadori, @asmeurer, @akheron
Superseder
  • bpo-45544: Close 2to3 issues and list them here
  • Files
  • issue12613.patch: Patch against 2to3 tip
  • 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.23:00:55.905>
    created_at = <Date 2011-07-22.16:49:31.763>
    labels = ['type-bug', 'expert-2to3']
    title = 'itertools fixer fails'
    updated_at = <Date 2021-10-20.23:00:55.905>
    user = 'https://bugs.python.org/VPeric'

    bugs.python.org fields:

    activity = <Date 2021-10-20.23:00:55.905>
    actor = 'iritkatriel'
    assignee = 'none'
    closed = True
    closed_date = <Date 2021-10-20.23:00:55.905>
    closer = 'iritkatriel'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2011-07-22.16:49:31.763>
    creator = 'VPeric'
    dependencies = []
    files = ['22878']
    hgrepos = []
    issue_num = 12613
    keywords = ['patch', 'needs review']
    message_count = 4.0
    messages = ['140897', '141836', '141893', '221605']
    nosy_count = 6.0
    nosy_names = ['benjamin.peterson', 'eric.araujo', 'VPeric', 'meador.inge', 'Aaron.Meurer', 'petri.lehtinen']
    pr_nums = []
    priority = 'high'
    resolution = 'wont fix'
    stage = 'resolved'
    status = 'closed'
    superseder = '45544'
    type = 'behavior'
    url = 'https://bugs.python.org/issue12613'
    versions = ['Python 2.7', 'Python 3.4', 'Python 3.5']

    @VPeric
    Copy link
    Mannequin Author

    VPeric mannequin commented Jul 22, 2011

    The itertools fixer (izip -> zip, among others), fails for the following code:

    from itertools import izip
    print msg % str(bool(symbol_swapped) and list(izip(*swap_dict).next()) or symbols)

    It gets converted to:

    print(msg % str(bool(symbol_swapped) and list(next(izip(*swap_dict))) or symbols))

    (note how izip is still there)

    I've worked aroudn this by introducing tmp = izip(...) and using that, but it'd be nice if 2to3 caught it by default.

    @VPeric VPeric mannequin added the topic-2to3 label Jul 22, 2011
    @akheron
    Copy link
    Member

    akheron commented Aug 9, 2011

    A smaller snippet to reproduce:

    izip().next()
    

    This gets converted to:

        next(izip())

    It seems to me that the pattern of the itertools fixer doesn't match to izip().something(), and thus this is skipped.

    @meadori
    Copy link
    Member

    meadori commented Aug 11, 2011

    I see two problems that cause the posted test cases to fail:

    1. The 'next' fixer runs before the 'itertools' fixer and strips
      out a 'power' node. This keeps the 'itertools' fixer from
      matching.

    2. The 'itertools' fixer does not handle any 'trailer' nodes after
      the itertool function application it is transforming.

    I have fixed both of these issues in the attached patch. Full test suite run; no regressions.

    @meadori meadori added the type-bug An unexpected behavior, bug, or error label Aug 11, 2011
    @BreamoreBoy
    Copy link
    Mannequin

    BreamoreBoy mannequin commented Jun 26, 2014

    The patch is small and looks clean to me. Can someone take a look with a view to committing please, thanks.

    @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