diff options
author | Anthony Sottile <asottile@umich.edu> | 2019-01-18 11:30:28 -0800 |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2019-01-18 21:30:28 +0200 |
commit | 74176226179ed56ad1c910bec5c4100e72ab4e84 (patch) | |
tree | f389c2d62a2852f04f969dba54edd6d93eb974d2 /Lib/ast.py | |
parent | 39ed289a3511d2e9bf0950a9d5dc53c8194f61b9 (diff) | |
download | cpython-git-74176226179ed56ad1c910bec5c4100e72ab4e84.tar.gz |
bpo-35733: Make isinstance(ast.Constant(boolean), ast.Num) be false. (GH-11547)
Diffstat (limited to 'Lib/ast.py')
-rw-r--r-- | Lib/ast.py | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/Lib/ast.py b/Lib/ast.py index 4c8c7795ff..03b8a1b16b 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -346,7 +346,10 @@ class _ABC(type): except AttributeError: return False else: - return isinstance(value, _const_types[cls]) + return ( + isinstance(value, _const_types[cls]) and + not isinstance(value, _const_types_not.get(cls, ())) + ) return type.__instancecheck__(cls, inst) def _new(cls, *args, **kwargs): @@ -384,3 +387,6 @@ _const_types = { NameConstant: (type(None), bool), Ellipsis: (type(...),), } +_const_types_not = { + Num: (bool,), +} |