Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Incorrect function resolution when calling overloads from python with keyword args #1097

Open
@jmlidbetter

Description

@jmlidbetter

Environment

  • Pythonnet version: 2.4.0
  • Python version: 3.6.5
  • Operating System: Centos

Details

  • Describe what you were trying to get done.

    When calling .NET functions with overloads from python with keyword args, the MethodBinder.Bind method will return the first method it finds which might not be the actual method the user is trying to call. Take the following simple C# code:

publicstaticstringOptionalArgumentsMethod(intarg1,intarg2){return$"{arg1}{arg2}XX";}publicstaticstringOptionalArgumentsMethod(intarg1,intarg2,intarg3=3){return$"{arg1}{arg2}{arg3}X";}publicstaticstringOptionalArgumentsMethod(intarg1,intarg2,intarg3=4,intarg4=5){return$"{arg1}{arg2}{arg3}{arg4}";}

Calling, for example,OptionalArgumentsMethod(1, 2, arg3=5) we expect to get back125X but instead we see:

>>>OptionalArgumentsMethod(1,2)'12XX'>>>OptionalArgumentsMethod(1,2,3)'123X'>>>OptionalArgumentsMethod(1,2,arg3=5)'12XX'>>>OptionalArgumentsMethod(1,2,3,5)'1235'>>>OptionalArgumentsMethod(1,2,3,arg4=5)'123X'>>>OptionalArgumentsMethod(1,2,arg4=0)'12XX'

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


      [8]ページ先頭

      ©2009-2025 Movatter.jp