You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Issue16376.diff: Change BYTE definition fron c_byte to c_ubyte
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
GitHub fields:
assignee=Noneclosed_at=Nonecreated_at=<Date2012-10-31.17:02:55.557>labels= ['ctypes', 'type-bug', '3.9', '3.10', '3.11']
title='wrong type for wintypes.BYTE'updated_at=<Date2021-06-17.10:29:15.374>user='https://bugs.python.org/techtonik'
This bug can cause people to make grave mistakes when using WIndows APIs. Im assuming this is a simple fix too.
Just because "cbytes" tests pass does not mean practical tests will pass. Take for example https://stackoverflow.com/a/6156606/7732434
Run this code as shown and then run the code with types ctypes.c_ubyte instead of wintypes.BYTE. You can see that the latter works as expected according to Microsofts own specs as seen in the link below.
Activity
techtonik commentedon Oct 31, 2012
Windows BYTE type is unsigned char, but ctypes defines it as signed.
{{{ BYTE A byte (8 bits). This type is declared in WinDef.h as follows: typedef unsigned char BYTE; typedef unsigned char BYTE; }}} http://msdn.microsoft.com/en-us/library/windows/desktop/aa383751(v=vs.85).aspxhttp://hg.python.org/cpython/file/e5f39546989f/Lib/ctypes/wintypes.py#l4
BreamoreBoy commentedon Jul 13, 2014
All cbytes tests passed after the change was made but I've no idea as to the impact of this.
elibroftw commentedon Sep 25, 2022
This bug can cause people to make grave mistakes when using WIndows APIs. Im assuming this is a simple fix too.
Just because "cbytes" tests pass does not mean practical tests will pass. Take for example
https://stackoverflow.com/a/6156606/7732434
Run this code as shown and then run the code with types
ctypes.c_ubyteinstead ofwintypes.BYTE. You can see that the latter works as expected according to Microsofts own specs as seen in the link below.https://learn.microsoft.com/en-us/windows/win32/api/winbase/ns-winbase-system_power_status
This would be a
wintypes.BYTEtest that would not passgh-60580: Fix a wrong type of `ctypes.wintypes.BYTE` (#97579)
pythongh-60580: Fix a wrong type of `ctypes.wintypes.BYTE` (python#97579
arhadthedev commentedon Feb 4, 2023
Fixed by gh-97579; no backporting is planned.