Disable implicit conversion from PyFloat to .NET integer types #1343
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
What does this implement/fix? Explain your changes.
Previously, when a floating point value was passed to .NET parameter of integer type, it would be silently truncated. After this change it would no longer be permitted to pass a floating point value to integer parameter.
Does this close any currently open issues?
#1342
Any other comments?
I removed poorly-behaved
PyLong_As*functions, as they would always implicitly convert argument to integer type, which in most cases is undesired behavior. Instead, to avoid roundtrips,PyLong_AsSize_tis used in most cases. The only exception isInt64which on 32 bit platforms is larger thansize_t, soPyLong_AsLongLongfunction is used after explicit check forPyLong.Draft because it depends on C# 9, which is not yet ready.
Checklist
Check all those that are applicable and complete.
CHANGELOG