Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PythonNET unknown kwargs being discarded #2360

Open
dmitry-medvedev opened this issue Apr 19, 2024 · 0 comments
Open

PythonNET unknown kwargs being discarded #2360

dmitry-medvedev opened this issue Apr 19, 2024 · 0 comments

Comments

@dmitry-medvedev
Copy link

dmitry-medvedev commented 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

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

No branches or pull requests

1 participant