New submission from Christian Kothe: 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). ---------- components: ctypes messages: 273732 nosy: Christian Kothe priority: normal severity: normal status: open title: ctypes docs must be more explicit about the type a func returns type: enhancement versions: Python 2.7, Python 3.2, Python 3.3, Python 3.4, Python 3.5 _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue27871> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com