Skip to content

PyFloats should not be implicitly rounded to integers #1342

@tminka

Description

@tminka

Environment

  • Pythonnet version: Latest master
  • Python version: 3.7.8
  • Operating System: Windows 10 64-bit
  • .NET Runtime: Core 3.1

Details

Incorrectly passing a float value to a method accepting an integer argument causes the float value to be rounded.

from Python.Test import MethodTest
MethodTest.TestOverloadedNoObject(5.5)

Surprisingly, the above code invokes the method with the integer 5. I expect this to raise an error instead, even if the value passed was 5.0. I expect a method with an integer argument to behave like list indexing in Python, which refuses any float value:

a = [1,2,3]
a[1.0]
TypeError: list indices must be integers or slices, not float

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions