When a python script run by an ActiveScripting scripting host application
on Python 3.4 scripting engine (with pywin32 Build 219)
throws a 'com_error' exception
during execution (IActiveScript::SetScriptState(SCRIPTSTATE_CONNECTED)),
then a TypeError is thrown in the course of handling the original exception,
and the original 'com_error' is lost.
The reason, as far as I understand, is the obsolete (for Python 3) code
accessing class attributes (exception class, in this case) by integer index.
Here is the trace:
...
pythoncom error: Unexpected exception in gateway method 'SetScriptState'
Traceback (most recent call last):
File "C:\Program Files\Python34\lib\site-packages\win32com\server\policy.py", line 325, in InvokeEx
return self.invokeex(dispid, lcid, wFlags, args, kwargs, serviceProvider)
File "C:\Program Files\Python34\lib\site-packages\win32com\server\policy.py", line 586, in invokeex
return func(*args)
File "C:\Program Files\Python34\lib\site-packages\win32comext\axscript\client\framework.py", line 610, in SetScriptState
self.Run()
File "C:\Program Files\Python34\lib\site-packages\win32comext\axscript\client\framework.py", line 788, in Run
self.ExecutePendingScripts()
File "C:\Program Files\Python34\lib\site-packages\win32comext\axscript\client\framework.py", line 736, in ExecutePendingScripts
self.DoExecutePendingScripts()
File "C:\Program Files\Python34\lib\site-packages\win32comext\axscript\client\pyscript.py", line 238, in DoExecutePendingScripts
self.ExecInScriptedSection(codeBlock, globs)
File "C:\Program Files\Python34\lib\site-packages\win32comext\axscript\client\framework.py", line 908, in ExecInScriptedSection
self.HandleException(codeBlock)
File "C:\Program Files\Python34\lib\site-packages\win32comext\axscript\client\framework.py", line 945, in HandleException
if issubclass(pythoncom.com_error, exc_type) and exc_value[0]==axscript.SCRIPT_E_REPORTED:
TypeError: 'com_error' object does not support indexing
...
The attached patch fixes it.
Very similar patch:
https://sourceforge.net/p/pywin32/patches/140/
Thanks, applied in this changeset:
http://pywin32.hg.sourceforge.net/hgweb/pywin32/pywin32/hgroot/pywin32/pywin32?cmd=changeset;node=c13cc925af27