Ensure Win32 resize hooks removed during shutdown#3587
Ensure Win32 resize hooks removed during shutdown#3587MelkorBalrog wants to merge 1 commit intomainfrom
Conversation
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| try: | ||
| _HOOKS.discard(self) | ||
| except Exception: | ||
| pass | ||
| return |
There was a problem hiding this comment.
Win32 hook finalizer skips uninstall during shutdown
When sys.is_finalizing() is true, _Win32WindowProcHook.__del__ now drops the hook from _HOOKS and returns without calling uninstall, so the patched window procedure remains installed while the CFUNCTYPE callback is being torn down. During interpreter shutdown WindowResizeController.__del__ also exits immediately (window_resizer.py:333-334), so hooks created by controllers are collected via this branch and never reach the new atexit cleanup (the hook has already been removed from _HOOKS). On Windows any late WM messages in that window tear-down window will then call a freed callback, risking crashes precisely during interpreter exit—the scenario this change was meant to prevent.
Useful? React with 👍 / 👎.
Summary
Testing
Codex Task