You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Need fixer for dl (removed) -> ctypes module #46722
If nobody else is interested in or currently in the process of making a
fixer for this, I can do it. I'm not sure if I completely understand the
changes I need to make though. Importing dl needs to be replaced by
importing ctypes, calls to dl.open() need to be replaced by calls to
ctypes.CDLL(), and calls to call() from an open dl object need to be
replaced to calls to funcname, where funcname is the first argument to
call(). Also, any strings in the other arguments should be preceded with
b to make them byte objects. Is this all that needs doing or am I
missing something else? Are there more complicated cases that I should
also take into account?
collinwinter commented on Aug 4, 2008
collinwintermannequin
Mannequin
More actions
I'd prefer it if someone better-versed in ctypes/dl wrote this fixer (or
at the very least, someone with access to Windows to test the translation).
Activity
nnorwitz commentedon Mar 24, 2008
r61837 removed the dl module. It needs a 2to3 fixer written to use ctypes.
loewis commentedon Mar 24, 2008
Is it possible to write one? I'm skeptical.
collinwinter commentedon Mar 24, 2008
Can you list the mapping you'd like to see? I've never used dl or
ctypes, so I'm not immediately sure how to port from one to the other.
loewis commentedon Mar 24, 2008
In the simplest case, convert
to
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:
theller commentedon Mar 25, 2008
Yes, this is correct.
theller commentedon Mar 25, 2008
Thomas Heller schrieb:
Currently, in py3k, ctypes only passed bytes objects as char*; so
the strings should be translated to bytes literals:
benjaminp commentedon Jul 31, 2008
What's the status of this?
nedds commentedon Aug 4, 2008
If nobody else is interested in or currently in the process of making a
fixer for this, I can do it. I'm not sure if I completely understand the
changes I need to make though. Importing dl needs to be replaced by
importing ctypes, calls to dl.open() need to be replaced by calls to
ctypes.CDLL(), and calls to call() from an open dl object need to be
replaced to calls to funcname, where funcname is the first argument to
call(). Also, any strings in the other arguments should be preceded with
b to make them byte objects. Is this all that needs doing or am I
missing something else? Are there more complicated cases that I should
also take into account?
collinwinter commentedon Aug 4, 2008
I'd prefer it if someone better-versed in ctypes/dl wrote this fixer (or
at the very least, someone with access to Windows to test the translation).
theller commentedon Aug 7, 2008
I can review and try out the fixer if someone provides a patch. OTOH I
have never used the dl module.
Note that dl exposed a lot of RTLD_ constants that ctypes does not yet,
so there should be a patch for ctypes also.
florentx commentedon Oct 24, 2011
for the RTLD_ constants, refer to issue bpo-13226.
loewis commentedon Apr 19, 2012
Being open for four years, this is hardly critical.