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

Provide a local definition of user32.setTimer, user32.KillTimer and ole32.CoGetApartmentType on Windows #1605

Merged
merged 1 commit into from
Jul 1, 2024

Conversation

bramd
Copy link
Contributor

@bramd bramd commented Jun 29, 2024

By overriding the type definition of SetTimer, we prevent None being passed as the callback parameter. This causes problems when integrating Bleak in larger Windows applications that call SetTimer in this way.

By defining the function type definition locally, we don't override the global definition so existing code that uses None as a callback keeps working.

Pull Request Guidelines for Bleak

Before you submit a pull request, check that it meets these guidelines:

  1. If the pull request adds functionality, the docs should be updated.
  2. Modify the CHANGELOG.rst, describing your changes as is specified by the
    guidelines in that document.
  3. The pull request should work for Python 3.8+ on the following platforms:
    • Windows 10, version 16299 (Fall Creators Update) and greater
    • Linux distributions with BlueZ >= 5.43
    • OS X / macOS >= 10.11
  4. Squash all your commits on your PR branch, if the commits are not solving
    different problems and you are committing them in the same PR. In that case,
    consider making several PRs instead.
  5. Feel free to add your name as a contributor to the AUTHORS.rst file!

@dlech
Copy link
Collaborator

dlech commented Jun 29, 2024

Thanks for the PR! I agree that since Bleak is a library, it shouldn't be modifying Python globals like this. We should fix the other functions as well.

@bramd bramd changed the title Provide a local definition of user32.setTimer on Windows Provide a local definition of user32.setTimer, user32.KillTimer and ole32.CoGetApartmentType on Windows Jun 30, 2024
@bramd
Copy link
Contributor Author

bramd commented Jun 30, 2024

@dlech Good idea to do the other functions as well. I've updated the PR to do this and also made sure to run black this time.

@dlech
Copy link
Collaborator

dlech commented Jun 30, 2024

Thanks for updating!

Could you add CHANGELOG entry too?

…le32.CoGetApartmentType on Windows

By overriding the type definition of SetTimer, we prevent None being passed as the callback parameter. This causes problems when integrating Bleak in larger Windows applications that call SetTimer in this way.
By defining the function type definition locally, we don't override the global definition so existing code that uses None as a callback keeps working.

To prevent other problems, we also make the definitions of KillTimer and CoGetApartmentType local.
@dlech dlech merged commit 3d2b0ec into hbldh:develop Jul 1, 2024
13 checks passed
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 this pull request may close these issues.

2 participants