From 6015cc50bc38b9e920ce4986ee10658eaa14f561 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 28 Oct 2018 13:43:03 +0200 Subject: 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. --- Lib/ast.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'Lib/ast.py') diff --git a/Lib/ast.py b/Lib/ast.py index de3df1473e..4c8c7795ff 100644 --- a/Lib/ast.py +++ b/Lib/ast.py @@ -346,7 +346,7 @@ class _ABC(type): 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): -- cgit v1.2.1