mirror of
https://github.com/pybind/pybind11.git
synced 2026-06-05 20:54:53 +00:00
enum_: fix implicit conversion on Python 2.7
Enumerations on Python 2.7 were not always implicitly converted to integers (depending on the target size). This patch adds a __long__ conversion function (only enabled on 2.7) which fixes this issue. The attached test case fails without this patch.
This commit is contained in:
@@ -65,4 +65,8 @@ test_initializer enums([](py::module &m) {
|
||||
.value("EFirstMode", ClassWithUnscopedEnum::EFirstMode)
|
||||
.value("ESecondMode", ClassWithUnscopedEnum::ESecondMode)
|
||||
.export_values();
|
||||
|
||||
m.def("test_enum_to_int", [](int) { });
|
||||
m.def("test_enum_to_uint", [](uint32_t) { });
|
||||
m.def("test_enum_to_long_long", [](long long) { });
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user