mirror of
https://github.com/python/cpython.git
synced 2025-12-04 00:30:19 +00:00
bpo-35733: Make isinstance(ast.Constant(boolean), ast.Num) be false. (GH-11547)
This commit is contained in:
parent
39ed289a35
commit
7417622617
3 changed files with 13 additions and 1 deletions
|
|
@ -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,),
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue