[BUG]: py::enum_
class creates a new object when calling MyEnumType(value)
rather than returns the cached instance
#5092
Labels
triage
New bug, unverified
Required prerequisites
What version (or hash if on master) of pybind11 are you using?
2.11.1
Problem description
I'm using
enum_value is MyEnum.NAME
in my code to test whether the given value is the expected enum value. It works fine when the EnumType is created usingenum.Enum
from the Python side. After I changed the implementation to C++ usingpy::enum_
, my CI tests failed when usinglhs_enum is rhs_enum
(butlhs_enum == rhs_enum
works as expected). It creates a new enum object each time when a bounded function returns an enum object.Reproducible example code
Python implementation:
C++ implementation:
Is this a regression? Put the last known working version here if it is.
Not a regression
The text was updated successfully, but these errors were encountered: