Eryk Sun <eryk...@gmail.com> added the comment:
A function that returns a pointer needs an explicit `restype` set. A function parameter that's a pointer generally requires `argtypes` to be set. For example: _testdll.GetPointer.restype = ctypes.c_void_p _testdll.SetPointer.argtypes = (ctypes.c_void_p,) Unfortunately the ctypes documentation starts with a tutorial that promotes bad practices and misuses WinAPI GetModuleHandle multiple times, which gives people the wrong idea about pointer return values. However, the tutorial does mention that Python integers are passed as C int values by default and that C int is the default return type. It also shows how to use the `argtypes` and `restype` attributes. ---------- nosy: +eryksun resolution: -> not a bug stage: -> resolved status: open -> closed _______________________________________ Python tracker <rep...@bugs.python.org> <https://bugs.python.org/issue42311> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com