[pywin32-bugs] [ pywin32-Patches-1578151 ] Patch for Testing Parameter Problem
OLD project page for the Python extensions for Windows
Brought to you by:
mhammond
From: SourceForge.net <no...@so...> - 2007-06-03 13:27:38
|
Patches item #1578151, was opened at 2006-10-16 23:25 Message generated for change (Comment added) made by mhammond You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=1578151&group_id=78018 Please note that this message will contain a full copy of the comment thread, including the initial issue submission, for this request, not just the latest update. Category: None Group: None Status: Open Resolution: None Priority: 5 Private: No Submitted By: bkssmith (bkssmith) Assigned to: Nobody/Anonymous (nobody) Summary: Patch for Testing Parameter Problem Initial Comment: 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. ---------------------------------------------------------------------- >Comment By: Mark Hammond (mhammond) Date: 2007-06-03 23:27 Message: 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... ---------------------------------------------------------------------- You can respond by visiting: https://sourceforge.net/tracker/?func=detail&atid=551956&aid=1578151&group_id=78018 |