Menu

#141 Bug in ActiveScripting exception handling

Unstable (example)
closed-fixed
nobody
None
5
2015-08-24
2015-03-24
timur
No

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.

1 Attachments

Discussion

  • timur

    timur - 2015-03-24
     
  • Mark Hammond

    Mark Hammond - 2015-08-24
    • status: open --> closed-fixed
     

Log in to post a comment.