Commit af056b65 by Henry Schreiner Committed by GitHub

fix: __index__ on Enum should always be present. (#3700)

* chore: minor odd py version cleanup

* Update include/pybind11/pybind11.h

* fix: always make __index__ available
parent 1b841883
...@@ -153,9 +153,6 @@ ...@@ -153,9 +153,6 @@
/// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode /// Include Python header, disable linking to pythonX_d.lib on Windows in debug mode
#if defined(_MSC_VER) #if defined(_MSC_VER)
# if (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION < 4)
# define HAVE_ROUND 1
# endif
# pragma warning(push) # pragma warning(push)
// C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only) // C4505: 'PySlice_GetIndicesEx': unreferenced local function has been removed (PyPy only)
# pragma warning(disable: 4505) # pragma warning(disable: 4505)
......
...@@ -1911,13 +1911,10 @@ public: ...@@ -1911,13 +1911,10 @@ public:
def(init([](Scalar i) { return static_cast<Type>(i); }), arg("value")); def(init([](Scalar i) { return static_cast<Type>(i); }), arg("value"));
def_property_readonly("value", [](Type value) { return (Scalar) value; }); def_property_readonly("value", [](Type value) { return (Scalar) value; });
def("__int__", [](Type value) { return (Scalar) value; }); def("__int__", [](Type value) { return (Scalar) value; });
def("__index__", [](Type value) { return (Scalar) value; });
#if PY_MAJOR_VERSION < 3 #if PY_MAJOR_VERSION < 3
def("__long__", [](Type value) { return (Scalar) value; }); def("__long__", [](Type value) { return (Scalar) value; });
#endif #endif
#if PY_MAJOR_VERSION > 3 || (PY_MAJOR_VERSION == 3 && PY_MINOR_VERSION >= 8)
def("__index__", [](Type value) { return (Scalar) value; });
#endif
attr("__setstate__") = cpp_function( attr("__setstate__") = cpp_function(
[](detail::value_and_holder &v_h, Scalar arg) { [](detail::value_and_holder &v_h, Scalar arg) {
detail::initimpl::setstate<Base>(v_h, static_cast<Type>(arg), detail::initimpl::setstate<Base>(v_h, static_cast<Type>(arg),
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment