Add note about calling Blender-defined constructor in multi-inheritance cases
`super()` is using the MRO to find the first `__init__()` function, if the blender-defined type is not the first inherited type, it may never be called that way. See #133183
This commit is contained in:
@@ -211,6 +211,19 @@ otherwise Blender's internal initialization won't happen properly:
|
||||
the only caller of these functions. The actual arguments passed to the constructor are fully
|
||||
internal data, and may change depending on the implementation.
|
||||
|
||||
.. note::
|
||||
|
||||
In case you are using complex/multi-inheritance, `super()` may not work. It is best then to
|
||||
explicitly invoke the Blender-defined parent class constructor. For example:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
import bpy
|
||||
class FancyRaytracer(AwesomeRaytracer, bpy.types.RenderEngine):
|
||||
def __init__(self, *args, **kwargs):
|
||||
bpy.types.RenderEngine.__init__(self, *args, **kwargs)
|
||||
...
|
||||
|
||||
.. note::
|
||||
|
||||
Defining a custom ``__new__()`` function is strongly discouraged, not tested, and not considered
|
||||
|
||||
Reference in New Issue
Block a user