Python 2.7 on Windows:
from ctypes import wintypes
print wintypes.BYTE # ctypes.c_byte
MSDN
A BYTE - 8 bit.
typedef unsigned char BYTE
Python 2.7 on Windows:
from ctypes import wintypes
print wintypes.BYTE # ctypes.c_byte
MSDN
A BYTE - 8 bit.
typedef unsigned char BYTE
Copyright © 2021 Jogjafile Inc.
As @ErykSun mentioned in his comment, it's an old bug which somehow got away.
It was however spotted (here are a couple of URLs - surely there are more):
[GitHub]: python/cpython - wrong type for wintypes.BYTE (since late 2012)
[SO]: In Python, how can I detect whether the computer is on battery power? (@BenHoyt's answer)
But it was fixed by [GitHub]: python/cpython - gh-60580: Fix a wrong type of ctypes.wintypes.BYTE (on 20230126 - I was just about to submit a PR myself, if I didn't find this one).
So, the first version that will have it right, is Python 3.12.
Usually (when it really matters) I do:
Things (CTypes related) that would (probably) worth reading:
Signed / unsigned types: [SO]: Maximum and minimum value of C types integers from Python (@CristiFati's answer)
Common function calling pitfall: [SO]: C function called from Python via ctypes returns incorrect value (@CristiFati's answer)