Skip to content

2to3 fix for operator.isCallable() #76227

Closed

Description

@serhiy-storchaka
BPO 32046
Nosy @benjaminp, @merwok, @berkerpeksag, @serhiy-storchaka, @ilevkivskyi, @corona10
PRs
  • bpo-32046: Update 2to3 when converts operator.isCallable(obj). #4417
  • 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 2018-08-02.23:52:19.273>
    created_at = <Date 2017-11-16.09:09:32.818>
    labels = ['3.7', 'type-feature', 'expert-2to3']
    title = '2to3 fix for operator.isCallable()'
    updated_at = <Date 2018-08-02.23:52:19.270>
    user = 'https://github.com/serhiy-storchaka'

    bugs.python.org fields:

    activity = <Date 2018-08-02.23:52:19.270>
    actor = 'berker.peksag'
    assignee = 'none'
    closed = True
    closed_date = <Date 2018-08-02.23:52:19.273>
    closer = 'berker.peksag'
    components = ['2to3 (2.x to 3.x conversion tool)']
    creation = <Date 2017-11-16.09:09:32.818>
    creator = 'serhiy.storchaka'
    dependencies = []
    files = []
    hgrepos = []
    issue_num = 32046
    keywords = ['patch']
    message_count = 6.0
    messages = ['306346', '306454', '307142', '307143', '321608', '322998']
    nosy_count = 6.0
    nosy_names = ['benjamin.peterson', 'eric.araujo', 'berker.peksag', 'serhiy.storchaka', 'levkivskyi', 'corona10']
    pr_nums = ['4417']
    priority = 'normal'
    resolution = 'fixed'
    stage = 'resolved'
    status = 'closed'
    superseder = None
    type = 'enhancement'
    url = 'https://bugs.python.org/issue32046'
    versions = ['Python 3.7']

    Activity

    1. serhiy-storchaka commented on Nov 16, 2017

      @serhiy-storchaka
      MemberAuthor

      Currently 2to3 converts operator.isCallable(obj) to hasattr(obj, '__call__'). This looks cumbersome, and can be deceived by instance attribute call. The more correct way is to use isinstance(obj, collections.abc.Callable). Starting from Python 3.2 it can use the callable() builtin.

    2. added
      3.7 (EOL)
      type-feature
      on Nov 16, 2017
    3. gvanrossum commented on Nov 17, 2017

      @gvanrossum
      Member

      I would convert this to callable() -- the conversion to collections.abc.Callable is more verbose and requires an extra import (that can be slow).

    4. merwok commented on Nov 28, 2017

      @merwok
      Member

      New changeset a489599 by Éric Araujo (Dong-hee Na) in branch 'master':
      bpo-32046: Update 2to3 when converts operator.isCallable(obj). (bpo-4417)
      a489599

    5. merwok commented on Nov 28, 2017

      @merwok
      Member

      Merged in master, I suppose stable branches should be left alone?

    6. corona10 commented on Jul 13, 2018

      @corona10
      Member

      @serhiy.storchaka
      If we don't have plans with backporting patches than we can close this issue.

    7. berkerpeksag commented on Aug 2, 2018

      @berkerpeksag
      Member

      I suppose stable branches should be left alone?

      We do backport lib2to3 PRs to maintenance branches, but since this is already in 3.7 and 3.6 is four months away from being in security-fix-only mode, I think we can close this as 'fixed' now.

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

      3.7 (EOL)topic-2to3type-feature

      Projects

      No projects

        Milestone

        No milestone

        Relationships

        None yet

        Development

        No branches or pull requests

        Issue actions