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

Select correct method to invoke when keyword arguments are used#1242

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
filmor merged 1 commit intopythonnet:masterfromdanabr:wrong-arity-with-kwargs
Oct 1, 2020
Merged
Show file tree
Hide file tree
Changes fromall commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletionsCHANGELOG.md
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -22,6 +22,7 @@ details about the cause of the failure
- Fix incorrect dereference in params array handling
- Fix `object[]` parameters taking precedence when should not in overload resolution
- Fixed a bug where all .NET class instances were considered Iterable
- Fix incorrect choice of method to invoke when using keyword arguments.

## [2.5.0][] - 2020-06-14

Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/constructorbinder.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -89,7 +89,7 @@ internal object InvokeRaw(IntPtr inst, IntPtr args, IntPtr kw, MethodBase info)
// any extra args are intended for the subclass' __init__.

IntPtr eargs = Runtime.PyTuple_New(0);
binding = Bind(inst, eargs,kw);
binding = Bind(inst, eargs,IntPtr.Zero);
Runtime.XDecref(eargs);

if (binding == null)
Expand Down
2 changes: 1 addition & 1 deletionsrc/runtime/methodbinder.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -580,7 +580,7 @@ static bool MatchesArgumentCount(int positionalArgumentCount, ParameterInfo[] pa
var match = false;
paramsArray = parameters.Length > 0 ? Attribute.IsDefined(parameters[parameters.Length - 1], typeof(ParamArrayAttribute)) : false;

if (positionalArgumentCount == parameters.Length)
if (positionalArgumentCount == parameters.Length && kwargDict.Count == 0)
{
match = true;
}
Expand Down
6 changes: 6 additions & 0 deletionssrc/testing/methodtest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -699,6 +699,12 @@ public string PublicMethod(string echo)
return echo;
}
}

public class MethodArityTest
{
public string Foo(int a) { return "Arity 1"; }
public string Foo(int a, int b) { return "Arity 2"; }
}
}

namespace PlainOldNamespace
Expand Down
7 changes: 7 additions & 0 deletionssrc/tests/test_method.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -1149,3 +1149,10 @@ def test_optional_and_default_params():

res = MethodTest.OptionalAndDefaultParams2(b=2, c=3)
assert res == "0232"

def test_keyword_arg_method_resolution():
from Python.Test import MethodArityTest

ob = MethodArityTest()
assert ob.Foo(1, b=2) == "Arity 2"


[8]ページ先頭

©2009-2025 Movatter.jp