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

Bad params object[] precedence (master)#1224

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
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@@ -19,6 +19,7 @@ details about the cause of the failure

- Fix incorrect dereference of wrapper object in `tp_repr`, which may result in a program crash
- Fix incorrect dereference in params array handling
- Fix `object[]` parameters taking precedence when should not in overload resolution

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

Expand Down
20 changes: 10 additions & 10 deletionssrc/runtime/methodbinder.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -203,6 +203,16 @@ internal static int ArgPrecedence(Type t)
return 3000;
}

if (t.IsArray)
{
Type e = t.GetElementType();
if (e == objectType)
{
return 2500;
}
return 100 + ArgPrecedence(e);
}

TypeCode tc = Type.GetTypeCode(t);
// TODO: Clean up
switch (tc)
Expand DownExpand Up@@ -250,16 +260,6 @@ internal static int ArgPrecedence(Type t)
return 40;
}

if (t.IsArray)
{
Type e = t.GetElementType();
if (e == objectType)
{
return 2500;
}
return 100 + ArgPrecedence(e);
}

return 2000;
}

Expand Down
3 changes: 2 additions & 1 deletionsrc/testing/methodtest.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
using System;
using System.IO;
using System.Linq;
using System.Runtime.InteropServices;

namespace Python.Test
Expand DownExpand Up@@ -84,7 +85,7 @@ public Type[] TestNullArrayConversion(Type[] v)

public static string[] TestStringParamsArg(params string[] args)
{
return args;
return args.Concat(new []{"tail"}).ToArray();
}

public static object[] TestObjectParamsArg(params object[] args)
Expand Down
9 changes: 6 additions & 3 deletionssrc/tests/test_method.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -206,17 +206,20 @@ def test_null_array_conversion():
def test_string_params_args():
"""Test use of string params."""
result = MethodTest.TestStringParamsArg('one', 'two', 'three')
assert result.Length ==3
assert len(result) ==3, result
assert result.Length ==4
assert len(result) ==4, result
assert result[0] == 'one'
assert result[1] == 'two'
assert result[2] == 'three'
# ensures params string[] overload takes precedence over params object[]
assert result[3] == 'tail'

result = MethodTest.TestStringParamsArg(['one', 'two', 'three'])
assert len(result) ==3
assert len(result) ==4
assert result[0] == 'one'
assert result[1] == 'two'
assert result[2] == 'three'
assert result[3] == 'tail'


def test_object_params_args():
Expand Down

[8]ページ先頭

©2009-2025 Movatter.jp