Skip to content

Fix Python failure handling in Pythonwin/pywin/framework/scriptutils.py#2319

Open
Avasam wants to merge 21 commits intomhammond:mainfrom
Avasam:scriptutils-handle-failure
Open

Fix Python failure handling in Pythonwin/pywin/framework/scriptutils.py#2319
Avasam wants to merge 21 commits intomhammond:mainfrom
Avasam:scriptutils-handle-failure

Conversation

@Avasam
Copy link
Copy Markdown
Collaborator

@Avasam Avasam commented Jul 25, 2024

and improve error message

The previous code would produce a TypeError: cannot unpack non-iterable SyntaxError object on SyntaxError

Comment thread CHANGES.txt Outdated
else:
traceback.print_exc()
win32ui.SetStatusText("Failed to " + what + " - " + str(details))
win32ui.SetStatusText(f"Failed to {what} - {type(details)} - {details}")
Copy link
Copy Markdown
Collaborator Author

@Avasam Avasam Jul 25, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Deduplicated win32ui.SetStatusText.

I have also considered the following:

Suggested change
win32ui.SetStatusText(f"Failed to {what} - {type(details)} - {details}")
win32ui.SetStatusText(f"Failed to {what} - {details!r}")

@Avasam Avasam force-pushed the scriptutils-handle-failure branch from c851363 to d285d40 Compare October 4, 2024 22:56
@Avasam Avasam requested a review from mhammond October 18, 2024 18:40
try:
msg, (fileName, line, col, text) = details
Copy link
Copy Markdown
Collaborator Author

@Avasam Avasam Mar 26, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This code would previously have produced:
TypeError: cannot unpack non-iterable SyntaxError object

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant