File tree 2 files changed +10
-9
lines changed 2 files changed +10
-9
lines changed Original file line number Diff line number Diff line change @@ -1566,6 +1566,10 @@ template <typename Type> class enum_ : public class_<Type> {
1566
1566
#if PY_MAJOR_VERSION < 3
1567
1567
def (" __long__" , [](Type value) { return (Scalar) value; });
1568
1568
#endif
1569
+ #if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8
1570
+ def (" __index__" , [](Type value) { return (Scalar) value; });
1571
+ #endif
1572
+
1569
1573
cpp_function setstate (
1570
1574
[](Type &value, Scalar arg) { value = static_cast <Type>(arg); },
1571
1575
is_method (*this ));
Original file line number Diff line number Diff line change @@ -192,15 +192,12 @@ def test_binary_operators():
192
192
193
193
194
194
def test_enum_to_int ():
195
- import sys
196
- # Implicit conversion to integers is deprecated in Python >= 3.8
197
- if sys .version_info < (3 , 8 ):
198
- m .test_enum_to_int (m .Flags .Read )
199
- m .test_enum_to_int (m .ClassWithUnscopedEnum .EMode .EFirstMode )
200
- m .test_enum_to_uint (m .Flags .Read )
201
- m .test_enum_to_uint (m .ClassWithUnscopedEnum .EMode .EFirstMode )
202
- m .test_enum_to_long_long (m .Flags .Read )
203
- m .test_enum_to_long_long (m .ClassWithUnscopedEnum .EMode .EFirstMode )
195
+ m .test_enum_to_int (m .Flags .Read )
196
+ m .test_enum_to_int (m .ClassWithUnscopedEnum .EMode .EFirstMode )
197
+ m .test_enum_to_uint (m .Flags .Read )
198
+ m .test_enum_to_uint (m .ClassWithUnscopedEnum .EMode .EFirstMode )
199
+ m .test_enum_to_long_long (m .Flags .Read )
200
+ m .test_enum_to_long_long (m .ClassWithUnscopedEnum .EMode .EFirstMode )
204
201
205
202
206
203
def test_duplicate_enum_name ():
You can’t perform that action at this time.
0 commit comments