Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error processing SyntaxError exception from a Python Script #2233

Closed
nbbeatty opened this issue Mar 28, 2024 · 1 comment · May be fixed by #2236
Closed

Error processing SyntaxError exception from a Python Script #2233

nbbeatty opened this issue Mar 28, 2024 · 1 comment · May be fixed by #2236

Comments

@nbbeatty
Copy link
Contributor

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]

@Avasam
Copy link
Collaborator

Avasam commented Apr 1, 2024

Closed by #2235

@Avasam Avasam closed this as completed Apr 1, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants