[python-win32] Python crash after win32com.client.CastTo?

Nathan Edwards nedwards at umiacs.umd.edu
Mon Mar 21 15:46:26 CET 2005


I'm going out of my mind here, trying to figure out if
a) I'm screwing up,
b) Python's COM extensions are screwing up, or
c) the Type Library I'm using is screwing up.

I have a small amount of experience with Visual Basic, but no experience 
of the intricacies of COM interfaces. However, I am "merely" attempting 
to port VB code that is known to work to a less restricted context (python).

The relevant code snippet looks like this:

   Dim theFMANSpecData As New FMANSpecData
   Dim theWF As FMANWiffFile
   Dim theWF2 As IFMANWiffFile2

   theFMANSpecData.wiffFilename = wiffFilename
   Set theWF = theFMANSpecData.GetWiffFileObject
   Set theWF2 = theWF

   ....
	
   Call theWF2.GetScanDescription2(1, 0, 382, 1, 0, ScanDesc, fixedMass)

I've used makepy to ensure static binding, and translated to this 
snippet as follows:

	from win32com.client import Dispatch, CastTo
         theFMANSpecData = Dispatch('Analyst.FMANSpecData')
	theFMANSpecData.WiffFileName = wiffFilename
         theWF = theFMANSpecData.GetWiffFileObject()
         theWF2 = CastTo(theWF,'IFMANWiffFile2')

	...

	ScanDesc, fixedMass = theWF2.GetScanDescription2(1,0,382,1,0)

I've used many of the other elements of the Analyst application's 
typelibs - they have all worked fine. This is the only case where a 
non-default interface to a class is required.

When the python interpreter hits the call to GetScanDescription2, it 
exits immediately, no exception, no error message, no nothing. Exit 
status 5 (cygwin shell), %errorlevel% -1073741819 from cmd.exe prompt.

Python 2.4, pywin32-203 for Python 2.4.

I'm not even sure how to proceed to debug the problem.

The type library is propriatary (provided by an instrument vendor). 
While it is possible the fault lies in that code, the library is used 
(and run by me on the same computer) by the VB code snippet above.

python exits abruptly with no error message whether or not I use the 
python binary or the pythonwin binary.

By inserting print statements into win32com/client/__init__.py, I've 
established that the crash is occuring in the call to 
self._oldobj_.InvokeTypes(...) in DispatchBaseClass._ApplyTypes_.

Having established this, I'm pretty confident of b) above.

The arguements to InvokeTypes are:

dispid = 1610678272
wFlags = 1
retType = (24, 0)
argTypes = ((3, 1), (3, 1), (3, 1), (3, 1), (3, 1), (16392, 2), (16389, 2))
args = (1, 0, 382, 1, 0, <PyOleMissing object at 0x009AF640>, 
<PyOleMissing object at 0x009AF640>)

If this is a bug in pywin, is this enough information to fix it? If not, 
how can I generate more helpful information?

Thanks!

nathan

nathan

-- 
Nathan Edwards, Ph.D.
Center for Bioinformatics and Computational Biology
3119 Agriculture/Life Sciences Surge Building #296
University of Maryland, College Park, MD 20742-3360
Phone: +1 301-405-9901
Email: nedwards at umiacs.umd.edu
WWWeb: http://www.umiacs.umd.edu/~nedwards



More information about the Python-win32 mailing list