Message273732
The ctypes documentation leaves an important detail very implicit, which can cause non-deterministic hard crashes when overlooked. The issue is that when you explicitly set the .restype of a function to c_void_p, the function returns not a c_void_p (like a newcomer might assume) but an int -- and when he/she passes that value into the next library function (which should have gotten a c_void_p), then they'll get a hard crash if that memory location lies outside the 32-bit range.
I take it that the implicit assumption in ctypes is that the data types that you get back from the library calls are native python types where applicable for convenience, and the restype (just like argtypes) only configures the marshaling layer. However, that's not very explicitly stated anywhere (except maybe between the lines). |
|
Date |
User |
Action |
Args |
2016-08-26 21:43:23 | Christian Kothe | set | recipients:
+ Christian Kothe |
2016-08-26 21:43:23 | Christian Kothe | set | messageid: <1472247803.52.0.0680824647216.issue27871@psf.upfronthosting.co.za> |
2016-08-26 21:43:23 | Christian Kothe | link | issue27871 messages |
2016-08-26 21:43:23 | Christian Kothe | create | |
|