Message402582
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_char,
pointer,
)
class MyStruct(Structure):
_fields_ = [("a", c_char), ("b", c_char), ("c", c_char)]
x: MyStruct = MyStruct(98, 99, 100)
print(type(x.a))
# Prints <class 'bytes'> ??? Both mypy and PyRight agree that x.a is a c_char.
some_variable = pointer(x.a)
# Traceback (most recent call last):
# File "C:\Users\cires\ctypes_test.py", line 23, in <module>
# some_variable = pointer(x.a)
# TypeError: _type_ must have storage info |
|
Date |
User |
Action |
Args |
2021-09-24 19:23:45 | ciresnave | set | recipients:
+ ciresnave |
2021-09-24 19:23:45 | ciresnave | set | messageid: <1632511425.07.0.917515072933.issue45285@roundup.psfhosted.org> |
2021-09-24 19:23:45 | ciresnave | link | issue45285 messages |
2021-09-24 19:23:44 | ciresnave | create | |
|