2010/11/9 Tim Roberts <t...@probo.com>: > Åsmund Hjulstad wrote: >> I keep getting the following exception when making some calls on a >> ActiveX DLL library (PISDK). Problem partially solved, posting in case >> others may find it usefull. >> >> TypeError: The Python instance can not be converted to a COM object >> >> I have traced it down to an optional parameter, that is set to 0, but >> should (probably) be set to None. >> >> the makepy signature is: >> >> GetPoints(self, WhereClause=<PyOleEmpty object>, pAsynchStatus=0) >> >> Doing the call using >> >> server.GetPoints(" tag = 'FT12345/*' ", None) >> >> works fine. ... >> >> As the optional parameter is easy to forget, especially when querying >> interactively in ipython, is it possible to make makepy understand >> that the optional parameter should be None, instead of 0? > > Makepy makes an educated guess, based on the data type of the > parameter. However, some people lie about their data types when they > make an interface like this. Instead of declaring it a pointer, they'll > declare it as an integer. Makepy isn't omniscient. > > Do you have the IDL that describes the function, or a web page > reference? Can you show us the script that makepy generated?
The function is described like this in the accompanying .h file: ( This is from pisdk.h ) virtual /* [helpstring][helpcontext][id] */ HRESULT STDMETHODCALLTYPE GetPoints( /* [in] */ BSTR whereClause, /* [in] */ PointSearchTypeConstants eSearchType, /* [defaultvalue][in] */ /* external definition not present */ _NamedValues *pnvExtraTableList, /* [defaultvalue][in] */ /* external definition not present */ _NamedValues *pnvServerList, /* [defaultvalue][in] */ /* external definition not present */ _PIAsynchStatus *pAsynchStatus, /* [retval][out] */ _PointList **ret) = 0; with _PIAsynchStatus described in pisdkcommon.h interface _PIAsynchStatus { CONST_VTBL struct _PIAsynchStatusVtbl *lpVtbl; }; There are two different DLLs, pisdk.dll and PISDKCommon.dll (which the first one depends on) The generated python code for the relevant method is # Result is of type _PointList def GetPoints(self, WhereClause=defaultNamedNotOptArg, pAsynchStatus=0): """Search for PIPoints on this server.""" ret = self._oleobj_.InvokeTypes(21, LCID, 1, (9, 0), ((8, 1), (9, 49)),WhereClause , pAsynchStatus) if ret is not None: ret = Dispatch(ret, u'GetPoints', '{EF9DDE15-265F-11D2-80F4-00A0240B7FDC}') return ret Please let me know if more information can be of help. _______________________________________________ python-win32 mailing list python-win32@python.org http://mail.python.org/mailman/listinfo/python-win32