[Python-Dev] Sign of bytes

Amaury Forgeot d'Arc amauryfa at gmail.com
Wed Oct 31 21:45:50 CET 2012


2012/10/31 anatoly techtonik <techtonik at gmail.com>:
> I wonder why Python uses signed chars for bytes
> http://docs.python.org/2/library/ctypes.html#ctypes.c_byte

c_int is signed, c_uint is unsigned.
similarly c_byte is signed, and c_ubyte is unsigned.

> Windows implements BYTE as unsigned char, and it is in the same line as
> WORD, DWORD etc. The way you look at memory contents in assembly.

In this case you should use ctypes.wintypes.BYTE
... which is unfortunately defined as c_byte!
This is the bug :-(

-- 
Amaury Forgeot d'Arc


More information about the Python-Dev mailing list