bpo-32892: Support subclasses of base types in isinstance checks for AST constants. (GH-9934)
Some projects (e.g. Chameleon) create ast.Str containing an instance
of the str subclass.
diff --git a/Lib/ast.py b/Lib/ast.py
index de3df14..4c8c779 100644
--- a/Lib/ast.py
+++ b/Lib/ast.py
@@ -346,7 +346,7 @@
except AttributeError:
return False
else:
- return type(value) in _const_types[cls]
+ return isinstance(value, _const_types[cls])
return type.__instancecheck__(cls, inst)
def _new(cls, *args, **kwargs):