FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

An overload with a parameter of type `object` is not used · Issue #811 · pythonnet/pythonnet · GitHub

Repository navigation

An overload with a parameter of type object is not used #811

Closed

Description

Environment

  • Pythonnet version: 2.3.0
  • Python version: 3.6
  • Operating System: Win 10 x64 1809

Details

I am trying to get Python call my C# method, which has a parameter of type object with an instance of Python's KeyError.

var o = overloaded.ToPython();

dynamic callWithSelf = PythonEngine.Eval("lambda o: o.ObjOrClass(KeyError())");
callWithSelf(o);

Where ObjOrClass definition is: public void ObjOrClass(object _) => this.Value = Object;. The actual function body here is not important.

  • Error:
Python.Runtime.PythonException : TypeError : No method matches given arguments for ObjOrClass

Possibly related:

#265
#782

Thoughs

IMHO, Python.NET should create a PyObject and pass it here.

Activity

  1. added 2 commits that reference this issue on Feb 11, 2019
    e9712b4
    5c9fa40
  2. filmor commented on Mar 6, 2019

    Member

    Yes, it's a possibility to do that. The issue at hand is probably, that Python objects do not derive from System.Object and can thus not match the overload. Can you prepare a PR?

  3. lostmsu commented on Apr 14, 2019

    MemberAuthor

    @filmor I am not sure I understood your comment. You can see my fix in the commit e9712b4 above. This change is potentially backwards-incompatible in case there's a .NET method with two overloads, one having parameter type object, and another PyObject for some parameter.

  4. filmor commented on Apr 23, 2019

    Member

    I'll need to look into this, could you make a PR from this commit?

  5. added a commit that references this issue on Mar 3, 2020
    8ad1062
  6. added 2 commits that reference this issue on Jun 29, 2020
    16c4701
    d5e164a
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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


      Back | FazBrowse Home | New Git URL