Skip to content

get_real_instance_class throws TypeError #202

@korkmaz

Description

@korkmaz

There is a chance that polymorphic_ctype_id of an object can point a wrong non-proxy ContentType model. If that case happens polymorphic model's get_real_instance_class throws a TypeError instead of RuntimeError.

issubclass method is called with a None argument like issubclass(model_instance, None)

# Protect against bad imports (dumpdata without --natural) or other
# issues missing with the ContentType models.
if model is not None \
and not issubclass(model, self.__class__) \
and not issubclass(model, self.__class__._meta.proxy_for_model):
    raise RuntimeError("ContentType {0} for {1} #{2} does not point to a subclass!".format(
        self.polymorphic_ctype_id, model, self.pk,
    ))
    return model

Maybe above code should also check self.__class__._meta.proxy_for_model is a None or not before calling issubclass?

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions