Skip to content

Calling 'params' method with single argument fails #331

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 our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
limdaepl opened this issue Jan 23, 2017 · 1 comment
Closed

Calling 'params' method with single argument fails #331

limdaepl opened this issue Jan 23, 2017 · 1 comment
Labels

Comments

@limdaepl
Copy link

Environment

  • Pythonnet version: 2.1.0
  • Python version: 2.7.10
  • Operating System: Microsoft Windows 7 Professional 6.1.7601 Service Pack 1 Build 7601

Details

When calling a method with the params keyword with a single argument I get

TypeError: No method matches given arguments

To reproduce:

C#:

public class Foo
{
    public void Bar(params int[] values)
    {
        foreach (var value in values)
        {
            Console.WriteLine(value);
        }
    }
}

Python:

foo = Foo()

foo.Bar([2,3,5,7]) # works
foo.Bar(2,3,5,7) # works

foo.Bar([5]) # works
foo.Bar(5) # TypeError: No method matches given arguments

This is probably related to the meta-issue #265.

@den-run-ai den-run-ai added the bug label Jan 24, 2017
@den-run-ai den-run-ai added this to the 2.3.0 milestone Feb 2, 2017
@vmuriart vmuriart modified the milestones: 2.4.0, 2.3.0 Mar 10, 2017
@filmor filmor removed this from the 2.4.0 milestone Apr 12, 2019
filmor pushed a commit that referenced this issue May 16, 2020
Add a check to see if the last parameter is a params parameter. Set the correct flag to show that it is a paramsArray function.

Fixes #943 and #331.
AlexCatarino pushed a commit to QuantConnect/pythonnet that referenced this issue Jun 29, 2020
Add a check to see if the last parameter is a params parameter. Set the correct flag to show that it is a paramsArray function.

Fixes pythonnet#943 and pythonnet#331.
@filmor
Copy link
Member

filmor commented Jun 14, 2022

This should be solved by the referenced PR.

@filmor filmor closed this as completed Jun 14, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

4 participants