This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Christian Kothe
Recipients Christian Kothe
Date 2016-08-26.21:43:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1472247803.52.0.0680824647216.issue27871@psf.upfronthosting.co.za>
In-reply-to
Content
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).
History
Date User Action Args
2016-08-26 21:43:23Christian Kothesetrecipients: + Christian Kothe
2016-08-26 21:43:23Christian Kothesetmessageid: <1472247803.52.0.0680824647216.issue27871@psf.upfronthosting.co.za>
2016-08-26 21:43:23Christian Kothelinkissue27871 messages
2016-08-26 21:43:23Christian Kothecreate