When executing a Python script with a syntax error via Windows Scripting Host, the exception always comes back as "Unknown" with Python 3.10, 3.11 and 3.12
Expected behavior:
From Windows OnScriptError( IActiveScriptError * pSE )
EXCEPTINFO eiError;
pSE->GetExceptionInfo( &eiError );
eiError->bstrDescription should contain "invalid syntax" and info for line number and offset should be available.
Actual behavior:
eiError->bstrDescription contains "Unknown" and the line number and offset are 0.
The problem is in class AXScriptException:
The function _BuildFromSyntaxError that parses the SyntaxError exception has a tuple assignment that is failing because two new fields were added in 3.10 (end_lineno and end_offset).
The failing line in _BuildFromSyntaxError is:
(filename, lineno, offset, line) = value[1]
because value[1] starting with Python 3.10 now has six elements.
To be backwardly compatible with Python 3.7, 3.8 and 3.9 and not get an exception in 3.10, 3.11 and 3.12 I have coded:
filename = value[1][0]
lineno = value[1][1]
offset = value[1][2]
line = value[1][3]
When executing a Python script with a syntax error via Windows Scripting Host, the exception always comes back as "Unknown" with Python 3.10, 3.11 and 3.12
Expected behavior: From Windows OnScriptError( IActiveScriptError * pSE ) EXCEPTINFO eiError; pSE->GetExceptionInfo( &eiError );
eiError->bstrDescription should contain "invalid syntax" and info for line number and offset should be available.
Actual behavior: eiError->bstrDescription contains "Unknown" and the line number and offset are 0.
The problem is in class AXScriptException: The function _BuildFromSyntaxError that parses the SyntaxError exception has a tuple assignment that is failing because two new fields were added in 3.10 (end_lineno and end_offset).
The failing line in _BuildFromSyntaxError is: (filename, lineno, offset, line) = value[1] because value[1] starting with Python 3.10 now has six elements.
To be backwardly compatible with Python 3.7, 3.8 and 3.9 and not get an exception in 3.10, 3.11 and 3.12 I have coded: filename = value[1][0] lineno = value[1][1] offset = value[1][2] line = value[1][3]