Skip to content

winUser.WinTimer: ensure timerFunc is correctly wrapped as a TIMERPROC even when None.#18925

Merged
michaelDCurran merged 3 commits into
masterfrom
fixFuncTypes
Sep 15, 2025
Merged

winUser.WinTimer: ensure timerFunc is correctly wrapped as a TIMERPROC even when None.#18925
michaelDCurran merged 3 commits into
masterfrom
fixFuncTypes

Conversation

@michaelDCurran
Copy link
Copy Markdown
Member

@michaelDCurran michaelDCurran commented Sep 15, 2025

Link to issue number:

Fixes #18907
Fixes #18914

Summary of the issue:

Tightening up ctypes definitions for 64 bit means that ctypes may be more picky with what can be passed as an argument. In particular passing None to an argument that should be a callback now will fail.
The correct way is now to pass Functype(0) where Functype is the callback's ctypes definition.
So far just one call has been identified in #18914: SetTimer takes a TIMERPROC.

Description of user facing changes:

None.

Description of developer facing changes:

Description of development approach:

winUser.WinTimer now ensures that timerFunc is already, or is converted to, a TIMERPROC. Specifically ensuring None is converted to TIMERPROC(0).

Testing strategy:

Known issues with pull request:

None known.

Code Review Checklist:

  • Documentation:
    • Change log entry
    • User Documentation
    • Developer / Technical Documentation
    • Context sensitive help for GUI changes
  • Testing:
    • Unit tests
    • System (end to end) tests
    • Manual testing
  • UX of all users considered:
    • Speech
    • Braille
    • Low Vision
    • Different web browsers
    • Localization in other languages / culture than English
  • API is compatible with existing add-ons.
  • Security precautions taken.

Copilot AI review requested due to automatic review settings September 15, 2025 02:22
@michaelDCurran michaelDCurran requested a review from a team as a code owner September 15, 2025 02:22
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes a ctypes compatibility issue where passing None as a timer callback function to SetTimer fails in 64-bit environments due to stricter type checking. The fix ensures that timer functions are properly wrapped as TIMERPROC types, with None being converted to TIMERPROC(0).

  • Adds type conversion logic to handle different timerFunc input types
  • Ensures None values are properly converted to typed null function pointers
  • Maintains backward compatibility while fixing 64-bit ctypes strictness

Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread source/winUser.py Outdated
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

Copilot reviewed 1 out of 1 changed files in this pull request and generated 1 comment.


Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.

Comment thread source/winUser.py Outdated
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
@hwf1324
Copy link
Copy Markdown
Contributor

hwf1324 commented Sep 15, 2025

Run from source, confirmed #18907 has been fixed.

@michaelDCurran michaelDCurran enabled auto-merge (squash) September 15, 2025 04:52
@michaelDCurran michaelDCurran merged commit 4c8a201 into master Sep 15, 2025
72 of 77 checks passed
@michaelDCurran michaelDCurran deleted the fixFuncTypes branch September 15, 2025 04:55
@github-actions github-actions Bot added this to the 2026.1 milestone Sep 15, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

5 participants