← Winnitude! Search  ·  Reader Mode (1729 ms)
Links: Stay in Reader Retro Site Converter Retro Mode: OFF Original Page ↗
GITHUB · 11 LINKS

PythonNET unknown kwargs being discarded · Issue #2360 · pythonnet/pythonnet

Repository navigation

PythonNET unknown kwargs being discarded  #2360


New issue

New issue

Open
#2590
Open
PythonNET unknown kwargs being discarded #2360 #2590 Labels
bug

Description

@dmitry-medvedev's profile dmitry-medvedev opened on Apr 19, 2024

Environment

  • Pythonnet version: 3.0.3
  • Python version: 3.11
  • Operating System: Windows 10
  • .NET Runtime: .NET 8.0

Details

When accessing a .NET function using PythonNET, if a kwarg is incorrect or doesn't exist, it is discarded by the PythonNET execution engine

If I have a .NET function like this:

Public Function SomeFunction(name as String, age as String) as String
    Return $"{name} - {age}"
End Function

And I call it in PythonNET like this:

if __name__ == "__main__":
    name = "John"
    age = "3"
    SomeFunction(name, age=age, fake_arg="something")

The fake arg is discarded, and no error or exception is thrown. Python compiles as if the additional kwarg were not there. In this situation, normal Python would be throwing a TypeError.

This is an issue with a multiple kwargs in the methods/functions is that a user can easily misspell and result in unexpected behavior.

PythonDemo.zip

Metadata

Metadata

Assignees

No one assigned

    Labels


    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions