Issue 32046: 2to3 fix for operator.isCallable() (original) (raw)

Created on 2017-11-16 09:09 by serhiy.storchaka, last changed 2022-04-11 14:58 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 4417 merged corona10,2017-11-16 11:14
Messages (6)
msg306346 - (view) Author: Serhiy Storchaka (serhiy.storchaka) * (Python committer) Date: 2017-11-16 09:09
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.
msg306454 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2017-11-17 19:27
I would convert this to `callable()` -- the conversion to collections.abc.Callable is more verbose and requires an extra import (that can be slow).
msg307142 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2017-11-28 16:27
New changeset a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2 by Éric Araujo (Dong-hee Na) in branch 'master': bpo-32046: Update 2to3 when converts operator.isCallable(obj). (#4417) https://github.com/python/cpython/commit/a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2
msg307143 - (view) Author: Éric Araujo (eric.araujo) * (Python committer) Date: 2017-11-28 16:29
Merged in master, I suppose stable branches should be left alone?
msg321608 - (view) Author: Dong-hee Na (corona10) * (Python committer) Date: 2018-07-13 13:27
@serhiy.storchaka If we don't have plans with backporting patches than we can close this issue.
msg322998 - (view) Author: Berker Peksag (berker.peksag) * (Python committer) Date: 2018-08-02 23:52
> 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.
History
Date User Action Args
2022-04-11 14:58:54 admin set github: 76227
2018-08-02 23:52:19 berker.peksag set status: open -> closednosy: + berker.peksagmessages: + resolution: fixedstage: patch review -> resolved
2018-07-13 15:13:43 gvanrossum set nosy: - gvanrossum
2018-07-13 13:27:18 corona10 set messages: +
2017-11-28 16:29:21 eric.araujo set messages: +
2017-11-28 16:27:00 eric.araujo set messages: +
2017-11-17 19:27:57 gvanrossum set nosy: + gvanrossummessages: +
2017-11-16 18:26:02 eric.araujo set messages: -
2017-11-16 18:25:43 eric.araujo set nosy: + eric.araujomessages: +
2017-11-16 14:52:23 corona10 set nosy: + corona10
2017-11-16 11:14:20 corona10 set keywords: + patchstage: patch reviewpull_requests: + <pull%5Frequest4366>
2017-11-16 09:09:32 serhiy.storchaka create