Skip to content

docs: Add a note about calling Python C APIs on py::native_enum #5640

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions docs/classes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -583,6 +583,13 @@ The older ``py::enum_`` is not PEP 435 compatible
but remains supported indefinitely for backward compatibility.
New bindings should prefer ``py::native_enum``.

.. important::

The enum types created by ``py::native_enum`` are native Python types, while
the enum types created by the older ``py::enum_`` are C++ pybind11 types.
Developers **SHOULD NOT** call ``PyType_*`` Python C APIs on the enum types
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

First impression: I'm very confused.

Could you please explain more? E.g. provide an example of what exactly one might want to do with PyType_*?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created by ``py:native_enum``.

.. note::

The deprecated ``py::enum_`` is :ref:`documented here <deprecated_enum>`.
Expand Down
Loading