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.
Created on 2008年03月24日 06:24 by nnorwitz, last changed 2022年04月11日 14:56 by admin. This issue is now closed.
| Messages (12) | |||
|---|---|---|---|
| msg64394 - (view) | Author: Neal Norwitz (nnorwitz) * (Python committer) | Date: 2008年03月24日 06:24 | |
r61837 removed the dl module. It needs a 2to3 fixer written to use ctypes. |
|||
| msg64407 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2008年03月24日 09:12 | |
Is it possible to write one? I'm skeptical. |
|||
| msg64417 - (view) | Author: Collin Winter (collinwinter) * (Python committer) | Date: 2008年03月24日 16:08 | |
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. |
|||
| msg64419 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2008年03月24日 16:41 | |
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
|
|||
| msg64467 - (view) | Author: Thomas Heller (theller) * (Python committer) | Date: 2008年03月25日 08:44 | |
> 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.
|
|||
| msg64526 - (view) | Author: Thomas Heller (theller) * (Python committer) | Date: 2008年03月25日 22:41 | |
Thomas Heller schrieb: > Thomas Heller <theller@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) >> Currently, in py3k, ctypes only passed bytes objects as char*; so the strings should be translated to bytes literals: import ctypes libc = ctypes.CDLL("libc.so.6") iconv = libc.iconv_open(b"ISO-8859-1", b"ISO-8859-2") # ^ ^ print(iconv) |
|||
| msg70466 - (view) | Author: Benjamin Peterson (benjamin.peterson) * (Python committer) | Date: 2008年07月31日 02:02 | |
What's the status of this? |
|||
| msg70712 - (view) | Author: Nick Edds (nedds) | Date: 2008年08月04日 18:32 | |
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? |
|||
| msg70713 - (view) | Author: Collin Winter (collinwinter) * (Python committer) | Date: 2008年08月04日 18:40 | |
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). |
|||
| msg70854 - (view) | Author: Thomas Heller (theller) * (Python committer) | Date: 2008年08月07日 19:29 | |
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. |
|||
| msg146303 - (view) | Author: Florent Xicluna (flox) * (Python committer) | Date: 2011年10月24日 13:23 | |
for the RTLD_ constants, refer to issue #13226. |
|||
| msg158724 - (view) | Author: Martin v. Löwis (loewis) * (Python committer) | Date: 2012年04月19日 12:41 | |
Being open for four years, this is hardly critical. |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:56:32 | admin | set | github: 46722 |
| 2021年10月20日 22:40:57 | iritkatriel | set | resolution: duplicate -> wont fix |
| 2021年10月20日 22:36:58 | iritkatriel | set | status: open -> closed resolution: duplicate superseder: Close 2to3 issues and list them here stage: needs patch -> resolved |
| 2012年04月19日 12:41:20 | loewis | set | priority: critical -> normal messages: + msg158724 |
| 2011年10月24日 13:23:41 | flox | set | nosy:
+ flox messages: + msg146303 |
| 2010年05月29日 15:26:34 | meador.inge | set | type: enhancement stage: needs patch |
| 2008年08月07日 19:29:13 | theller | set | messages: + msg70854 |
| 2008年08月04日 18:40:07 | collinwinter | set | messages: + msg70713 |
| 2008年08月04日 18:32:39 | nedds | set | nosy:
+ nedds messages: + msg70712 |
| 2008年07月31日 02:02:38 | benjamin.peterson | set | nosy:
+ benjamin.peterson messages: + msg70466 |
| 2008年03月25日 22:41:57 | theller | set | messages: + msg64526 |
| 2008年03月25日 08:44:06 | theller | set | messages: + msg64467 |
| 2008年03月24日 16:41:37 | loewis | set | nosy:
+ theller messages: + msg64419 |
| 2008年03月24日 16:08:33 | collinwinter | set | messages: + msg64417 |
| 2008年03月24日 09:12:48 | loewis | set | nosy:
+ loewis messages: + msg64407 |
| 2008年03月24日 06:24:34 | nnorwitz | create | |