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 fix for operator.isCallable() #76227

Closed
serhiy-storchaka opened this issue Nov 16, 2017 · 6 comments
Closed

2to3 fix for operator.isCallable() #76227

serhiy-storchaka opened this issue Nov 16, 2017 · 6 comments
Labels
3.7 (EOL) end of life topic-2to3 type-feature A feature request or enhancement

Comments

@serhiy-storchaka
Copy link
Member

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

    @serhiy-storchaka
    Copy link
    Member Author

    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.

    @serhiy-storchaka serhiy-storchaka added 3.7 (EOL) end of life topic-2to3 type-feature A feature request or enhancement labels Nov 16, 2017
    @gvanrossum
    Copy link
    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).

    @merwok
    Copy link
    Member

    merwok commented Nov 28, 2017

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

    @merwok
    Copy link
    Member

    merwok commented Nov 28, 2017

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

    @corona10
    Copy link
    Member

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

    @berkerpeksag
    Copy link
    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.

    @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
    3.7 (EOL) end of life topic-2to3 type-feature A feature request or enhancement
    Projects
    None yet
    Development

    No branches or pull requests

    5 participants