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 eryksun
Recipients eryksun, sh4dow
Date 2020-11-10.16:46:38
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1605026798.76.0.706741221085.issue42311@roundup.psfhosted.org>
In-reply-to
Content
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.
History
Date User Action Args
2020-11-10 16:46:38eryksunsetrecipients: + eryksun, sh4dow
2020-11-10 16:46:38eryksunsetmessageid: <1605026798.76.0.706741221085.issue42311@roundup.psfhosted.org>
2020-11-10 16:46:38eryksunlinkissue42311 messages
2020-11-10 16:46:38eryksuncreate