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

Explicit float and int conversion for builtin types #1904

Merged
merged 3 commits into from Aug 12, 2022

Conversation

filmor
Copy link
Member

@filmor filmor commented Aug 10, 2022

Fixes #1896

@lostmsu
Copy link
Member

lostmsu commented Aug 10, 2022

I suggest we also add: int(System.Boolean), float(System.Boolean), and float(System.*Int*)
Anything else you can think of?

@filmor
Copy link
Member Author

filmor commented Aug 11, 2022

There are probably more valid conversions (Boolean to bool works already due to __int__), but I wouldn't want to actually change behaviour now. The implemented conversions are sensible and fix a "regression".

src/runtime/Types/ClassBase.cs Show resolved Hide resolved
src/runtime/Types/ClassBase.cs Outdated Show resolved Hide resolved
src/runtime/Types/ClassBase.cs Outdated Show resolved Hide resolved
tests/test_conversion.py Show resolved Hide resolved
Copy link
Member

@lostmsu lostmsu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comment about new tests

@filmor filmor merged commit 0909021 into pythonnet:release Aug 12, 2022
@filmor filmor deleted the float-int-cast branch August 12, 2022 04:07
@filmor filmor mentioned this pull request Aug 12, 2022
5 tasks
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.

None yet

2 participants