Skip to content

Commit cf230fb

Browse files
committed
Add a note in docs/classes.rst
1 parent b2b6663 commit cf230fb

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

docs/classes.rst

+12
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,18 @@ interactive Python session demonstrating this example is shown below:
5858
Static member functions can be bound in the same way using
5959
:func:`class_::def_static`.
6060

61+
.. note::
62+
63+
By default pybind11 uses a custom metaclass which is known to be
64+
incompatible with
65+
`abc.ABCMeta <https://docs.python.org/3/library/abc.html#abc.ABCMeta>`_
66+
and can also lead to other surprising issues. In such cases,
67+
using ``py::metaclass(PyType_Type)`` is often a good solution
68+
(e.g. ``py::class_<Pet>(m, "Pet", py::metaclass(PyType_Type))``).
69+
Please see
70+
`#5015 <https://github.com/pybind/pybind11/pull/5015>`_
71+
for more background.
72+
6173
.. note::
6274

6375
Binding C++ types in unnamed namespaces (also known as anonymous namespaces)

0 commit comments

Comments
 (0)