MCPcopy
hub / github.com/django/django / subclass_exception

Function subclass_exception

django/db/models/base.py:72–87  ·  view source on GitHub ↗

Create exception subclass. Used by ModelBase below. The exception is created in a way that allows it to be pickled, assuming that the returned exception class will be added as an attribute to the 'attached_to' class.

(name, bases, module, attached_to)

Source from the content-addressed store, hash-verified

70
71
72def subclass_exception(name, bases, module, attached_to):
73 """
74 Create exception subclass. Used by ModelBase below.
75
76 The exception is created in a way that allows it to be pickled, assuming
77 that the returned exception class will be added as an attribute to the
78 'attached_to' class.
79 """
80 return type(
81 name,
82 bases,
83 {
84 "__module__": module,
85 "__qualname__": "%s.%s" % (attached_to.__qualname__, name),
86 },
87 )
88
89
90def _has_contribute_to_class(value):

Callers 1

__new__Method · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected