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

Update methodbinder.cs#217

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

Closed
den-run-ai wants to merge1 commit intopythonnet:masterfromden-run-ai:patch-13
Closed
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
4 changes: 2 additions & 2 deletionssrc/runtime/methodbinder.cs
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -344,7 +344,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw,
if (clrtype != null)
{
bool typematch = false;
if (pi[n].ParameterType != clrtype)
if ((pi[n].ParameterType != clrtype) && !(pi[n].ParameterType.IsAssignableFrom(clrtype)))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

Isn't the != check redundant? It looks like checking !pi[n].ParameterType.IsAssignableFrom(clrtype) would be sufficient.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

This is a very good catch! But actually the logic is more complicated,
since sometimes multiple methods can matchIsAssignableFrom criteria for
the overloaded arguments.

So in addition to type equality really need to loop throughIsSubclassOf
and build a list sorted by proximity to the argument type.

On Thu, May 26, 2016 at 4:43 AM, Tony Robertsnotifications@github.com
wrote:

In src/runtime/methodbinder.cs
#217 (comment):

@@ -344,7 +344,7 @@ internal Binding Bind(IntPtr inst, IntPtr args, IntPtr kw)
if (clrtype != null)
{
bool typematch = false;

  •                            if (pi[n].ParameterType != clrtype)
  •                            if ((pi[n].ParameterType != clrtype) && !(pi[n].ParameterType.IsAssignableFrom(clrtype)))

Isn't the != check redundant? It looks like checking
!pi[n].ParameterType.IsAssignableFrom(clrtype) would be sufficient.


You are receiving this because you authored the thread.
Reply to this email directly or view it on GitHub
https://github.com/pythonnet/pythonnet/pull/217/files/5a8ae4f6b1a69ad96c17d894972556296b7fe513#r64718246

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

All I meant was that there can never be the case where pi[n].ParameterType == clrtype && !(pi[n].ParameterType.IsAssignableFrom(clrtype)), so this case is equivalent to checking that ParameterType is not assignable from clrtype.

Another way of saying this is that (ParameterType is not assignable from clrtype) implies (Parameter Type != clrtype). So, the expression as written is logically equivalent to simply (ParameterType is not assignable from clrtype).

{
IntPtr pytype = Converter.GetPythonTypeByAlias(pi[n].ParameterType);
pyoptype = Runtime.PyObject_Type(op);
Expand DownExpand Up@@ -603,4 +603,4 @@ internal Binding(MethodBase info, Object inst, Object[] args,
this.outs = outs;
}
}
}
}

[8]ページ先頭

©2009-2025 Movatter.jp