[issue2470] Need fixer for dl (removed) -> ctypes module

Thomas Heller report at bugs.python.org
Tue Mar 25 09:44:06 CET 2008


Thomas Heller <theller at ctypes.org> added the comment:

> In the simplest case, convert
> 
> import dl
> libc = dl.open("libc.so.6")
> iconv = libc.call("iconv_open", "ISO-8859-1", "ISO-8859-2")
> print(iconv)
> 
> to
> 
> import ctypes
> libc = ctypes.CDLL("libc.so.6")
> iconv = libc.iconv_open("ISO-8859-1", "ISO-8859-2")
> print(iconv)
> 
> Notice that <dlobject>.call has up to 11 arguments, the first one being
> the function name.
> 
> Thomas, is it the case that all calls to dl.call can be converted to a
> ctypes call without parameter conversion? dl supports these parameter
> types:
> - byte string, passed as char*
> - integers, passed as int
> - None, passed as NULL

Yes, this is correct.

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue2470>
__________________________________


More information about the Python-bugs-list mailing list