[IronPython] Misleading error messages

Ray Djajadinata rayfd_2000 at yahoo.com
Sun Sep 25 12:38:40 CEST 2005


Hello,

I'm playing around with list in IronPython 0.9.2, when
I found that error messages regarding the (wrong)
number of arguments passed into a function always
tells you that the function takes 0 argument:

<snippet>
>>> horsemen = ["Pestilence", "War", "Famine",
"WebSphere"]
>>> horsemen.count()
Traceback (most recent call last):
   at <shell>
TypeError: count() takes exactly 0 argument (1 given)
>>> horsemen.insert(1)
Traceback (most recent call last):
   at <shell>
TypeError: insert() takes exactly 0 argument (2 given)
</snippet>

This happens to built-in function as well:

<snippet>
>>> abs()
Traceback (most recent call last):
   at <shell>
TypeError: abs() takes exactly 0 argument (0 given)
</snippet>

This seems to be a problem with .NET Framework 2.0
instead of IP, though. In TypeGen.cs, line 114:

<snippet>
MethodBuilder mb = myType.DefineMethod(name, attrs,
retType, paramTypes);

return new CodeGen(this, mb, mb.GetILGenerator());
</snippet>

In that snippet above, although the paramTypes is a
Type[] of length 1 (created using makeArray() in
Constant.cs), somehow the MethodBuilder instance that
DefineMethod() returns has 0 argument. In the case of
abs() above, the property Signature prints:

{Name: abs 
Attributes: 22
Method Signature: Length: 4
Arguments: 0
Signature: 
0  0  28  28  0  


}

I've tried it with .NET Framework 1.1 (just the part
about creating the MethodBuilder) and the result is:

Length: 4
Arguments: 1
Signature:
0  1  28  28  0  

Cheers,
Ray

__________________________________________________
Do You Yahoo!?
Tired of spam?  Yahoo! Mail has the best spam protection around 
http://mail.yahoo.com 



More information about the Ironpython-users mailing list