[python-win32] IActiveScript::AddNamedItem fails with exception

Mark Hammond mhammond at skippinet.com.au
Thu Apr 5 01:16:47 CEST 2012

On 4/04/2012 8:20 PM, David Manns wrote:
> Mark,
> Thanks, that's better!
> Now I get this trace output:
> Collecting Python Trace Output...
> Object with win32trace dispatcher created (object=None)
>   in <win32com.axscript.client.pyscript.PyScript instance at
> 0x058BF300>._InvokeEx_-SetScriptSite(<PyIActiveScriptSite at 0x05806F58 with
> obj at 0x043F
> F22C>,) [1,0,None]
> Debugging interfaces not available - debugging is disabled..
> in <win32com.axscript.client.pyscript.PyScript instance at
> 0x058BF300>._InvokeEx_-InitNew() [1,0,None]
> in <win32com.axscript.client.pyscript.PyScript instance at
> 0x058BF300>._InvokeEx_-AddNamedItem(u'application', 14) [1,0,None]
> **************** ASSERTION FAILED *******************
> The typeKind of the object is unexpected
> in <win32com.axscript.client.pyscript.PyScript instance at
> 0x058BF300>._InvokeEx_-Close() [1,0,None]
> Hopefully that means more to you than it does to me!

FWIW, the implementation is all in python in the 
win32comext\axscript\client directory.  Grepping for this message shows 
it as appearing in framework.py in the function GetSourceTypeInfo(). 
This function is attempting to locate the possible events for an item, 
but it is only expecting the typeinfo to be one of TKIND_COCLASS or 
TKIND_INTERFACE - sadly it doesn't report what was actually found, but 
you might be able to determine that as it is your typeinfo being 
examined.  Assuming your objects don't actually have events, the 
simplest fix would be to just change:

		if typeKind not in [pythoncom.TKIND_COCLASS, pythoncom.TKIND_INTERFACE]:
			RaiseAssert(winerror.E_UNEXPECTED, "The typeKind of the object is 


		if typeKind not in [pythoncom.TKIND_COCLASS, pythoncom.TKIND_INTERFACE]:
                         return None

[Sadly there is also a bug in that RaiseAssert function - it has the 
args wrong when creating the exception - it should read 'raise 
Exception(desc, scode)', hence the E_UNEXPECTED is coming out as E_FAIL 
- but that's not really a big deal...]

Let me know if that works for you and I'll make that change for the next 



More information about the python-win32 mailing list