Skip to content

itertools fixer fails #56822

Closed
Closed

Description

@VPeric
mannequin
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']

    Activity

    1. VPeric commented on Jul 22, 2011

      VPericmannequin
      MannequinAuthor

      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.

    2. akheron commented on Aug 9, 2011

      @akheron
      Member

      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.

    3. meadori commented on Aug 11, 2011

      @meadori
      Member

      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.

    4. BreamoreBoy commented on Jun 26, 2014

      BreamoreBoymannequin
      Mannequin

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

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