Throw TypeError when subclasses forget to call __init__ (#2152)

- Fixes #2103
This commit is contained in:
Dustin Spicuzza
2020-07-07 06:04:06 -04:00
committed by GitHub
parent d54d6d8c61
commit 1b0bf352fa
3 changed files with 53 additions and 0 deletions

View File

@@ -149,6 +149,11 @@ memory for the C++ portion of the instance will be left uninitialized, which
will generally leave the C++ instance in an invalid state and cause undefined
behavior if the C++ instance is subsequently used.
.. versionadded:: 2.5.1
The default pybind11 metaclass will throw a ``TypeError`` when it detects
that ``__init__`` was not called by a derived class.
Here is an example:
.. code-block:: python