2

Python 2.7 on Windows:

from ctypes import wintypes
print wintypes.BYTE  # ctypes.c_byte

MSDN

A BYTE - 8 bit.

typedef unsigned char BYTE
CristiFati
  • 38,250
  • 9
  • 50
  • 87
Pavel Patrin
  • 1,630
  • 1
  • 19
  • 33
  • It's that way because Thomas Heller defined it as `c_byte` back in 2003, when the file was named [windows.py](http://ctypes.cvs.sourceforge.net/viewvc/ctypes/ctypes/win32/windows.py?hideattic=0&revision=1.1&view=markup), circa ctypes 0.6.0. – Eryk Sun Jun 24 '15 at 10:21

1 Answers1

1

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):

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:

from ctypes import wintypes as wts

# Other imports

wts.BYTE = cts.c_ubyte

# ...

Things (CTypes related) that would (probably) worth reading:

CristiFati
  • 38,250
  • 9
  • 50
  • 87