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

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions

      pFad - Phonifier reborn

      Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

      Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


      Alternative Proxies:

      Alternative Proxy

      pFad Proxy

      pFad v3 Proxy

      pFad v4 Proxy