Skip to content
New issue

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

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

Already on GitHub? # to your account

Improve the type safety of errorinfo.ReportException. #823

Merged
merged 2 commits into from
Feb 28, 2025

Conversation

junkmd
Copy link
Collaborator

@junkmd junkmd commented Feb 27, 2025

Due to the possibility that sys.exc_info()[2] and TracebackType.tb_next may return None, there are points in errorinfo.ReportException where the type checker will produce errors.

If this function is called with a specified stacklevel without catching an error, or if stacklevel is specified deeper than the cause of the error even when an error is caught, an AttributeError will be raised.

By explicitly detecting such cases and throwing a ValueError, the implementation of errorinfo.ReportException can be made type-safe.

@junkmd junkmd added the typing related to Python static typing system label Feb 27, 2025
@junkmd junkmd added this to the 1.4.11 milestone Feb 27, 2025
junkmd added a commit to junkmd/pywinauto that referenced this pull request Feb 27, 2025
@junkmd junkmd merged commit 4f6792d into enthought:main Feb 28, 2025
50 checks passed
@junkmd junkmd deleted the errorinfo branch February 28, 2025 00:14
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
typing related to Python static typing system
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant