Thanks, Michael, that will work.<br><br>It seems blindingly obvious now, but I hadn't even considered it, since I generally try to pass CLR types to CLR methods.<br><br>Sheepishly,<br>Eric<br><br><div><span class="gmail_quote">
On 7/30/07, <b class="gmail_sendername">Michael Foord</b> <<a href="mailto:fuzzyman@voidspace.org.uk">fuzzyman@voidspace.org.uk</a>> wrote:</span><blockquote class="gmail_quote" style="border-left: 1px solid rgb(204, 204, 204); margin: 0pt 0pt 0pt 0.8ex; padding-left: 1ex;">
Hello Eric,<br><br>Interestingly it works with:<br>pc = ParamCall(('a', 'b', 'c'))<br><br>passing a tuple instead of an array.<br><br>Still looks like a bug.<br><br>Michael<br><a href="http://www.ironpython.info/">
http://www.ironpython.info/</a><br><br>Eric Rochester wrote:<br>> Hi,<br>><br>> I've been using IronPython for a few months now, and I'm really<br>> enjoying it. Thanks for all the hard work that's gone into it.
<br>><br>> I recently ran across an issue, and I wondered if anyone else has seen<br>> it. I think it's probably a bug, but I couldn't find a bug report,<br>> either.<br>><br>> Basically, if there is a CLR class that takes an array as its only
<br>> constructor argument, IronPython always tries to call it using params.<br>> For example, if I compile this to ParamCall.dll:<br>><br>> // ParamCall.cs<br>><br>> using System;<br>><br>> namespace ParamCall
<br>> {<br>> public class ParamCall<br>> {<br>> private string[] args;<br>><br>> public ParamCall(string[] args)<br>> {<br>>
this.args = args;<br>> }<br>><br>> public string Joined()<br>> {<br>> return String.Join(",", args);<br>> }<br>> }<br>
> }<br>><br>><br>> And I call it using this script:<br>><br>> # paramcall.py<br>><br>> import clr<br>> clr.AddReference('ParamCall')<br>><br>> from ParamCall import ParamCall
<br>> from System import Array<br>><br>> args = Array[str]( ['a', 'b', 'c'] )<br>> print 'args =', args<br>><br>> print 'creating ParamCall object:'
<br>> pc = ParamCall(args)<br>> print 'pc.Joined() =>', pc.Joined()<br>><br>> print<br>><br>><br>> I get these results.<br>><br>> C:\home\eric\src\ase\Lse.Net>IronPython\ipy
paramcall.py<br>> args = System.String[]('a', 'b', 'c')<br>> creating ParamCall object:<br>> Traceback (most recent call last):<br>> File C:\home\eric\src\ase\Lse.Net\paramcall.py, line 7, in
<br>> Initialize<br>> File , line 0, in __import__##4<br>> File C:\home\eric\src\ase\Lse.Net\ParamCall.py, line 15, in<br>> Initialize<br>> File , line 0, in NonDefaultNew##54<br>> TypeError: ParamCall() takes exactly 1 argument (3 given)
<br>><br>><br>> I have also tried wrapping the arguments in a tuple and calling it<br>> like ParamCall( *(args,) ), but the results are the same.<br>><br>> If anyone has any suggestions for work-arounds or clues as to what I'm
<br>> doing wrong, I'd be glad to hear them.<br>><br>> Thanks,<br>><br>> --<br>> Eric Rochester<br>><br>> ------------------------------------------------------------------------<br>><br>> _______________________________________________
<br>> Users mailing list<br>> <a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br>> <a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">http://lists.ironpython.com/listinfo.cgi/users-ironpython.com
</a><br>><br><br>_______________________________________________<br>Users mailing list<br><a href="mailto:Users@lists.ironpython.com">Users@lists.ironpython.com</a><br><a href="http://lists.ironpython.com/listinfo.cgi/users-ironpython.com">
http://lists.ironpython.com/listinfo.cgi/users-ironpython.com</a><br></blockquote></div><br><br clear="all"><br>-- <br>Eric Rochester<br><a href="http://writingcoding.blogspot.com/">http://writingcoding.blogspot.com/</a><br>
<a href="http://www.linkedin.com/in/erochester">http://www.linkedin.com/in/erochester</a>