CireSnave added the comment:
Wow. Thank you Eryk Sun. While that seems like a convoluted way to make a
type act like the type it is...it works. Verified it with the following code:
from ctypes import POINTER, c_char, sizeof, Structure
class char_from_c(c_char):
pass
print("Size of
Eryk Sun added the comment:
A simple ctypes type implements a get function that's called when its value is
returned as an attribute of struct/union, index of an array/pointer, or result
of a function pointer. For example:
>>> a = (ctypes.c_char * 1)(97)
>>> a[0]
b'a'
>>> p =
New submission from CireSnave :
When dealing with a Structure containing c_char variables, the variables are
incorrectly being typed as bytes. As a result, a pointer to those c_char
variables can not be created because bytes is not a ctypes type.
from ctypes import (
Structure,
c_cha