Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
P
pybind11
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
open
pybind11
Commits
31680e6f
Commit
31680e6f
authored
Sep 20, 2019
by
Wenzel Jakob
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Implicit conversion from enum to int for Python 3.8 (fix by @sizmailov)
parent
5fd187eb
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
10 additions
and
9 deletions
+10
-9
include/pybind11/pybind11.h
+4
-0
tests/test_enum.py
+6
-9
No files found.
include/pybind11/pybind11.h
View file @
31680e6f
...
...
@@ -1566,6 +1566,10 @@ public:
#if PY_MAJOR_VERSION < 3
def
(
"__long__"
,
[](
Type
value
)
{
return
(
Scalar
)
value
;
});
#endif
#if PY_MAJOR_VERSION >= 3 && PY_MINOR_VERSION >= 8
def
(
"__index__"
,
[](
Type
value
)
{
return
(
Scalar
)
value
;
});
#endif
cpp_function
setstate
(
[](
Type
&
value
,
Scalar
arg
)
{
value
=
static_cast
<
Type
>
(
arg
);
},
is_method
(
*
this
));
...
...
tests/test_enum.py
View file @
31680e6f
...
...
@@ -192,15 +192,12 @@ def test_binary_operators():
def
test_enum_to_int
():
import
sys
# Implicit conversion to integers is deprecated in Python >= 3.8
if
sys
.
version_info
<
(
3
,
8
):
m
.
test_enum_to_int
(
m
.
Flags
.
Read
)
m
.
test_enum_to_int
(
m
.
ClassWithUnscopedEnum
.
EMode
.
EFirstMode
)
m
.
test_enum_to_uint
(
m
.
Flags
.
Read
)
m
.
test_enum_to_uint
(
m
.
ClassWithUnscopedEnum
.
EMode
.
EFirstMode
)
m
.
test_enum_to_long_long
(
m
.
Flags
.
Read
)
m
.
test_enum_to_long_long
(
m
.
ClassWithUnscopedEnum
.
EMode
.
EFirstMode
)
m
.
test_enum_to_int
(
m
.
Flags
.
Read
)
m
.
test_enum_to_int
(
m
.
ClassWithUnscopedEnum
.
EMode
.
EFirstMode
)
m
.
test_enum_to_uint
(
m
.
Flags
.
Read
)
m
.
test_enum_to_uint
(
m
.
ClassWithUnscopedEnum
.
EMode
.
EFirstMode
)
m
.
test_enum_to_long_long
(
m
.
Flags
.
Read
)
m
.
test_enum_to_long_long
(
m
.
ClassWithUnscopedEnum
.
EMode
.
EFirstMode
)
def
test_duplicate_enum_name
():
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment