-
-
Notifications
You must be signed in to change notification settings - Fork 100
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
Replace alias definitions with ctypes.wintypes imports for #662 #694
Merged
+7
−15
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
d16ef33
Replace alias definitions with ctypes.wintypes
fmtabler 5e7c842
Fix formatting in GUID.py and git.py
fmtabler 3005c61
Add noqa to DWORD import in __init__.py
fmtabler 4faed94
Fix formatting in __init__.py
fmtabler 96162f7
Fix space formatting in __init__.py
fmtabler File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You probably don't want to use BYTE
See this issue: python/cpython#60580
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to Microsoft Win32 API GUID documentation (https://learn.microsoft.com/en-us/windows/win32/api/guiddef/ns-guiddef-guid), the correct GUID structure would have unsigned chars for the Data4 field.
I think since ctypes.wintypes was updated to have BYTE = ctypes.c_ubyte here: python/cpython#97579, importing BYTE from ctypes.wintypes should be better aligned with the GUID structure than defining BYTE = c_byte in GUID.py.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, c_ubyte is the correct type.
My point is more that wintypes.DWORD = c_ubyte only since python 3.12.
So, for python 3.8 to 3.11, wintypes.DWORD = c_byte.
This may cause an unexpected behaviour because it is not the same value for all the supported python version
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moi15moi
Is
wintypes.DWORD
a typo forwintypes.BYTE
?(Both
DWORD
in 3.11 andDWORD
in 3.12 are aliases forc_ulong
, and neitherc_byte
norc_ubyte
.)Indeed, I overlooked python/cpython#60580. However, I believe this change is not breaking but rather a bug fix.
While it may have been possible to assign signed values to the
Data4
field in the past, this was limited to the scope ofctypes
structures.Such values should not have been allowed as part of a COM component.
Tests for
GUID
are already included in the CI pipeline, so I don't believe there is much to fear here.If we later discover that this change has unintended consequences after the release, we plan to revert the replacement of
BYTE
and release a new version.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, sorry about that.
To be sure that
BYTE
isc_ubyte
on any python version comtypes support, shouldn't we do this?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@moi15moi
I think that’s a great idea.
Feel free to open the PR!
Let’s also check if the tests in the CI pipeline pass there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I opened the issue about this: #696 (comment)