diff options
author | Dong-hee Na <donghee.na92@gmail.com> | 2017-11-28 16:26:56 (GMT) |
---|---|---|
committer | Éric Araujo <merwok@users.noreply.github.com> | 2017-11-28 16:26:56 (GMT) |
commit | a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2 (patch) | |
tree | a10f20e7292be409e720293bed9dbed87281c330 /Lib/lib2to3/fixes | |
parent | 598ceae876ff4a23072e59945597e945583de4ab (diff) | |
download | cpython-a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2.zip cpython-a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2.tar.gz cpython-a489599793f9b00ddc2c68e2ce3bce9cbb2c09a2.tar.bz2 |
bpo-32046: Update 2to3 when converts operator.isCallable(obj). (#4417)
Diffstat (limited to 'Lib/lib2to3/fixes')
-rw-r--r-- | Lib/lib2to3/fixes/fix_operator.py | 7 |
1 files changed, 3 insertions, 4 deletions
diff --git a/Lib/lib2to3/fixes/fix_operator.py b/Lib/lib2to3/fixes/fix_operator.py index 0d82454..d303cd2 100644 --- a/Lib/lib2to3/fixes/fix_operator.py +++ b/Lib/lib2to3/fixes/fix_operator.py @@ -1,6 +1,6 @@ """Fixer for operator functions. -operator.isCallable(obj) -> hasattr(obj, '__call__') +operator.isCallable(obj) -> callable(obj) operator.sequenceIncludes(obj) -> operator.contains(obj) operator.isSequenceType(obj) -> isinstance(obj, collections.abc.Sequence) operator.isMappingType(obj) -> isinstance(obj, collections.abc.Mapping) @@ -49,11 +49,10 @@ class FixOperator(fixer_base.BaseFix): def _sequenceIncludes(self, node, results): return self._handle_rename(node, results, "contains") - @invocation("hasattr(%s, '__call__')") + @invocation("callable(%s)") def _isCallable(self, node, results): obj = results["obj"] - args = [obj.clone(), String(", "), String("'__call__'")] - return Call(Name("hasattr"), args, prefix=node.prefix) + return Call(Name("callable"), [obj.clone()], prefix=node.prefix) @invocation("operator.mul(%s)") def _repeat(self, node, results): |