In version 2.4 the following code did the expected thing, i.e. invoked the defined __str__ overload for the enum when str() was used in Python code on an instance of that enum:
enum Pet {
Dog = 0,
Cat
};
auto pet = py::enum_<Pet>(m, "Pet", py::arithmetic(), "some pet")
.value("Dog", Dog)
.value("Cat", Cat)
.def("__str__", [](Pet p) { return p == Dog ? "Dog" : "Cat"; });
This does not work anymore in V2.6 (I have not checked in V2.5, though). V2.6 always returns either "Pet.Dog" or "Pet.Cat" and ignores the defined __str__.