Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

enum_: fix implicit conversion on Python 2.7 #821

Merged
merged 2 commits into from
Apr 29, 2017
Merged

Conversation

wjakob
Copy link
Member

@wjakob wjakob commented Apr 28, 2017

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.

@wjakob
Copy link
Member Author

wjakob commented Apr 28, 2017

Interesting -- looks like PyPy does not pass the new test even with the fix.

@wjakob
Copy link
Member Author

wjakob commented Apr 28, 2017

The solution to the puzzle is that PyPy generates a type error (rather than a 2.7.x-style system error) when a conversion to an arithmetic type fails. I added a patch that switches PyPy over to the 3.x convention. With that, the test suite now passes on PyPy as well.

Any thoughts on this patch?

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.
The added flag enables non-buffered console output when using Ninja
@dean0x7d
Copy link
Member

LGTM

@wjakob wjakob merged commit 7653a11 into pybind:master Apr 29, 2017
@dean0x7d dean0x7d modified the milestone: v2.2 Aug 13, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants