Skip to content

Explicit float and int conversion for builtin types#1904

Merged
filmor merged 3 commits into
pythonnet:releasefrom
filmor:float-int-cast
Aug 12, 2022
Merged

Explicit float and int conversion for builtin types#1904
filmor merged 3 commits into
pythonnet:releasefrom
filmor:float-int-cast

Conversation

@filmor

@filmor filmor commented Aug 10, 2022

Copy link
Copy Markdown
Member

Fixes #1896

@lostmsu

lostmsu commented Aug 10, 2022

Copy link
Copy Markdown
Member

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

@filmor

filmor commented Aug 11, 2022

Copy link
Copy Markdown
Member Author

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".

Comment thread src/runtime/Types/ClassBase.cs
Comment thread src/runtime/Types/ClassBase.cs Outdated
Comment thread src/runtime/Types/ClassBase.cs Outdated
Comment thread tests/test_conversion.py
Comment thread tests/test_conversion.py

@lostmsu lostmsu left a comment

Copy link
Copy Markdown
Member

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.

2 participants