[IronPython] "TypeError: Microsoft.Scripting.DynamicType is not callable" bug(?)
Martin
storm.openmail at gmail.com
Wed Jul 11 16:44:32 CEST 2007
Hi,
*Background:*
We have a number of Python scripts that we use for updating and setting up
the devices my company make. We do this through calls to a number of COM
classes via win32com.client.Dispatch().
We are interested in being able to call these Python scripts from various
.NET GUI applications written in C# so naturally I started looking into
IronPython.
My goal is to make our CPython code as executable in IronPython as humanly
possible so since win32com is not available through IronPython I wrote a
simple C# interop wrapper handling the interops for the specific COM classes
we need to call when setting up our devices:
namespace win32com
{
public class client
{
public static object Dispatch(string comName)
{
<rip>
}
}
}
The annoying thing is that this "hack" works like a charm except in one type
of case.
*Problem:*
Some of our COM classes return Item collections that are indexable by both
specific names (string indexing) and normal int indexes
- example in CPython:
result=win32com.client.Dispatch("COMClass")("ItemName") and/or
result=win32com.client.Dispatch("COMClass")(0)
This works like a charm in CPython (and the interop version of our C# code
for that matter) but it does NOT work in IronPython.
In IronPython 1.1 I get this error message "TypeError: object is not
callable"
In IronPython 2.0 alpha 3 I get this error message: "TypeError:
Microsoft.Scripting.DynamicType is not callable".
I can access the properties of the object such as item count however I
cannot index into the result object by calling result.get_Item("ItemName").
It gives the following error message
TypeError: multiple overloads of get_Item could match (String)
get_Item(Object)
get_Item(Object)
nor can I index into the result object by calling result.get_Item(0) which
gives a similar error except the problematic match is Int32.
So apparently IronPython cannot identify the type of the index objects when
more are present?
*Question*
**
Anyone have any comments that can help me here? Have I missed some subtle
issues with COM interop? Is this a known bug and if so when do you think it
will be fixed?
(I know I can get around the problem by writing specific IronPython code +
changing the handling of the COM class in my C# wrapper but I REALLY don't
want to nor should I have to if the goal is to make IronPython as clean as
possible port of CPython.)
PS.
Great initiative and great work otherwise in the port
BR
Martin Storm Møller
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ironpython-users/attachments/20070711/11d8644a/attachment.html>
More information about the Ironpython-users
mailing list