missing `UCHAR` in `ctypes.wintypes`.
hello :)
(terribly sorry, i might have accidentally sent an unfinished email before this!)
i'm creating a small module for interacting with SCSI devices, and i'm making use of ctypes
to interact with the win32 API for my windows implementation. in doing so, i've had to define my own version of the SCSI_PASS_THROUGH_DIRECT<https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddscsi/ns-ntddscsi-_scsi_pass_through_direct> struct using ctypes.Structure
. when reading around earlier today, i found the ctypes.wintypes
module and was happy to see that it could help me write my code to be more consistent with the definitions found in the win32 API. however, the UCHAR
type appears many times in that struct i mentioned, and yet is not defined in the ctypes.wintypes
module (in fact, it is commented out in the source with no reason given).
i understand that there is probably a reason that i'm unaware of for not having a definition of c_uchar
in the ctypes
module. however, i don't understand why an equivalent type (such as ctypes.c_ubyte
) hasn't been used to define UCHAR
in the ctypes.wintypes
module to maintain consistency with the windows API.
i know that it is a bit silly to make such a big deal over an alias, but the point of these aliases is to make code look more consistent, and that's hardly the case when there's an exception to the rule! :D
if this missing definition was intentional, then what is the reason behind that? or if it has been simply overlooked, then can the definition be created for the sake of consistency? i would love to make the relevant amendment myself if that is the case ^^
thanks! (and sorry again if the other email sent!)
kingsley mcdonald :)
Interesting… If you look at the source code for ctype.wintypes you’ll see that the definition of UCHAR is there, but specifically commented out. That was already so in the original commit of that section of the file (back in 2010).
So I really can’t tell you why UCHAR was specifically left out. I can guess that it is because it has a double meaning (sometimes you want to use it as an 8 bit unsigned int, sometimes you want to use it as a character in a character set that happens to have the top 128 codepoints defined), but now I’m just guessing.
On 09-Apr-2020, at 01:57 , Kingsley McDonald <kingsleymcdonald@outlook.com> wrote:
hello :)
(terribly sorry, i might have accidentally sent an unfinished email before this!)
i'm creating a small module for interacting with SCSI devices, and i'm making use of
ctypes
to interact with the win32 API for my windows implementation. in doing so, i've had to define my own version of the SCSI_PASS_THROUGH_DIRECT<https://docs.microsoft.com/en-us/windows-hardware/drivers/ddi/ntddscsi/ns-ntddscsi-_scsi_pass_through_direct> struct usingctypes.Structure
. when reading around earlier today, i found thectypes.wintypes
module and was happy to see that it could help me write my code to be more consistent with the definitions found in the win32 API. however, theUCHAR
type appears many times in that struct i mentioned, and yet is not defined in thectypes.wintypes
module (in fact, it is commented out in the source with no reason given).i understand that there is probably a reason that i'm unaware of for not having a definition of
c_uchar
in thectypes
module. however, i don't understand why an equivalent type (such asctypes.c_ubyte
) hasn't been used to defineUCHAR
in thectypes.wintypes
module to maintain consistency with the windows API.i know that it is a bit silly to make such a big deal over an alias, but the point of these aliases is to make code look more consistent, and that's hardly the case when there's an exception to the rule! :D
if this missing definition was intentional, then what is the reason behind that? or if it has been simply overlooked, then can the definition be created for the sake of consistency? i would love to make the relevant amendment myself if that is the case ^^
thanks! (and sorry again if the other email sent!)
kingsley mcdonald :)
capi-sig mailing list -- capi-sig@python.org To unsubscribe send an email to capi-sig-leave@python.org
-- Jack Jansen, <Jack.Jansen@cwi.nl>, http://www.cwi.nl/~jack If I can't dance I don't want to be part of your revolution -- Emma Goldman
participants (2)
-
Jack Jansen
-
Kingsley McDonald