[python-win32] Invalid number of parameters on makepy-generated method
Federico Fanton
federico at panizzolo.it
Wed Oct 6 10:01:11 CEST 2010
Mark Hammond wrote:
["Invalid number of parameters"]
>>> Is the exception coming from the InvokeTypes call?
>>
>> Exactly..
>> I have a new bit of information though: I noticed that the problem
>> arises ONLY when the controlled application (Alibre) is already running,
>> while if it's not, there's no exception... Could it be that the "Invalid
>> number of parameters" is thrown by something *after* the InvokeTypes?
>> That is, could it be an error of the API itself? Or would I get the
>> exception elsewhere?
>
> Assuming the exception is a COMException, then yeah, it is the COM
> object itself which is throwing the error - ie, it isn't Python
> complaining about the missing param.
It's a pywintypes.com_error.. I'm assuming that's equivalente to a
COMException then.
>> If I call the Close() method passing pythoncom.Missing, there's no error
>> even when Alibre is already open... Is Missing a way to explicitly tell
>> "I'm not passing you this parameter, use the default value"?
>
> Exactly - when 'Missing' is used, the win32com bridge doesn't pass
> anything for the arg (ie, the "number of params" Python indicates it has
> passed doesn't include that param). When it is called as generated by
> makepy though, the parameter is always passed, but using the default
> value supplied by the type-library if one isn't specified by the Python
> code.
>
> This just sounds like a bug in the COM object.
I see.. Many thanks for your assistance :)
More information about the python-win32
mailing list