Open ghost opened 18 years ago
Patches to test function parameter problem
Original comment by: bkssmith
Logged In: YES user_id=14198 Originator: NO
Re point (1) - that is just the nature of the beast when you don't have a typelib - python guesses best it can. I can't explain your other points though. I got as far as checking in your Method2, and a test that Python calls it correctly. I didn't get to adding the VB test though, but hopefully I will sooner rather than later...
Original comment by: mhammond
As requested by Mark, I have attached patches that demonstrate a problem I am having with parameter handling when using a Python COM Object from Visual Basic after creating a type library for the object.
Here are the two problems I am having, as originally reported on the pywin32 mailing list.
1) When using the COM server without the type library, I was returning a tuple with the return value of the function (in my case, an error code) as the first element. With the type library, this value must be the last element. It is my understanding that the return value for the function should be returned first, not last.
2) VBA was giving me an error like "Expecting 3 return values, got: 2" whenever a function contained an [in, out] parameter. It looks like the extra parameter it is looking for is the HRESULT signifying the success of the call itself, because if I insert a 0 at the beginning of my returned tuple the problem goes away but any other value causes an error saying the method call failed.
I was originally testing my own object using VBA in Excel 2000. Mark requested the patches to the pippo sample included with pywin32. The patch adds two methods with the same signature. The difference is that the Python implementation of Method2() returns two values (as the IDL signature would suggest) and Method3() returns 3 values, with a 0 as the first value. My VBA test code (also attached) calls Method3 () first and correctly sets inout1 to -31 and the return value to -41. Note that this occurs even though the function return value is the *last* return value. The call to Method2() fails with the "Expecting 3 return values, got: 2" error.
I have also tried using Visual Basic 2005 Express Edition and the behaviour is similar: the call to Method3() succeeds and the call to Method2() fails, although now the error is "Error HRESULT E_FAIL has been returned from a call to a COM component".
My platform is Win XP Pro (SP2), Python 2.3.4, pywin Build 210.
Reported by: bkssmith
Original Ticket: "pywin32/patches/73":https://sourceforge.net/p/pywin32/patches/73