def _class_type(klass, ancestors=None):
<EOL>if klass._type is not None:<EOL><INDENT>return klass._type<EOL><DEDENT>if _is_metaclass(klass):<EOL><INDENT>klass._type = "<STR_LIT>"<EOL><DEDENT>elif klass.name.endswith("<STR_LIT>"):<EOL><INDENT>klass._type = "<STR_LIT>"<EOL><DEDENT>else:<EOL><INDENT>if ancestors is None:<EOL><INDENT>ancestors = set()<EOL><DEDENT>klass_name = klass.qname()<EOL>if klass_name in ancestors:<EOL><INDENT>klass._type = "<STR_LIT:class>"<EOL>return "<STR_LIT:class>"<EOL><DEDENT>ancestors.add(klass_name)<EOL>for base in klass.ancestors(recurs=False):<EOL><INDENT>name = _class_type(base, ancestors)<EOL>if name != "<STR_LIT:class>":<EOL><INDENT>if name == "<STR_LIT>" and not _is_metaclass(klass):<EOL><INDENT>continue<EOL><DEDENT>klass._type = base.type<EOL>break<EOL><DEDENT><DEDENT><DEDENT>if klass._type is None:<EOL><INDENT>klass._type = "<STR_LIT:class>"<EOL><DEDENT>return klass._type<EOL>
return a ClassDef node type to differ metaclass and exception
    from 'regular' classes