[issue46966] c_void_p array is a footgun on I32LP64 systems

2022-03-09 Thread JP Sugarbroad
JP Sugarbroad added the comment: That matches our expectation. A subclass works - perhaps `c_void_p` could be deprecated in favor of a built-in subclass for generic opaque pointers as well? Glad you agree that a warning would be useful here. -- __

[issue46966] c_void_p array is a footgun on I32LP64 systems

2022-03-09 Thread Eryk Sun
Eryk Sun added the comment: > I'm not sure what can be done here (maybe a truncation warning?) For a function pointer, the default argument conversion for Python integers is the platform int type. Ideally, Python integer arguments would be converted to a type that matches the platform word s

[issue46966] c_void_p array is a footgun on I32LP64 systems

2022-03-08 Thread JP Sugarbroad
New submission from JP Sugarbroad : The following code will likely crash on I32LP64 systems: dim = lib.get_array_size(opaque) ptrs = (c_void_p * dim)() lib.get_array_values(opaque, ptrs) for ptr in ptrs: print(lib.get_object_value(ptr)) What happens is that `ptr` is not a `c_void_p` -- it'