py: Factor and improve issubclass.