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 2013年03月07日 13:58 by eli.bendersky, last changed 2022年04月11日 14:57 by admin. This issue is now closed.
| Files | ||||
|---|---|---|---|---|
| File name | Uploaded | Description | Edit | |
| issue17378.1.patch | eli.bendersky, 2013年03月07日 14:09 | |||
| Messages (5) | |||
|---|---|---|---|
| msg183661 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2013年03月07日 13:58 | |
While playing with ctypes a bit, I noticed a feature that doesn't appear to be documented. Suppose I import the readdir_r function (assuming DIRENT is a correctly declared ctypes.Structure): DIR_p = c_void_p DIRENT_p = POINTER(DIRENT) DIRENT_pp = POINTER(DIRENT_p) readdir_r = lib.readdir_r readdir_r.argtypes = [DIR_p, DIRENT_p, DIRENT_pp] readdir_r.restype = c_int It seems that I can then call it as follows: dirent = DIRENT() result = DIRENT_p() readdir_r(dir_fd, dirent, result) Note that while readdir_r takes DIRENT_p and DIRENT_pp as its second and third args, I pass in just DIRENT and DIRENT_p, accordingly. What I should have done is use byref() on both, but ctypes seems to have some magic applied when argtypes declares pointer types. If I use byref, it still works. However, if I keep the same call and comment out the argtypes declaration, I get a segfault. This behavior of ctypes should be documented. |
|||
| msg183663 - (view) | Author: Eli Bendersky (eli.bendersky) * (Python committer) | Date: 2013年03月07日 14:09 | |
Doc patch for 3.2 |
|||
| msg183668 - (view) | Author: Thomas Heller (theller) * (Python committer) | Date: 2013年03月07日 15:06 | |
Patch looks good. Please apply. |
|||
| msg183734 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年03月08日 13:33 | |
New changeset 76be5efa0d86 by Eli Bendersky in branch '3.2': Issue #17378: ctypes documentation fix. http://hg.python.org/cpython/rev/76be5efa0d86 New changeset 2cd2d8f8f72f by Eli Bendersky in branch '3.3': Issue #17378: ctypes documentation fix. http://hg.python.org/cpython/rev/2cd2d8f8f72f New changeset 58c07ba40926 by Eli Bendersky in branch 'default': Issue #17378: ctypes documentation fix. http://hg.python.org/cpython/rev/58c07ba40926 |
|||
| msg183735 - (view) | Author: Roundup Robot (python-dev) (Python triager) | Date: 2013年03月08日 13:35 | |
New changeset 2dd77a12e7bf by Eli Bendersky in branch '2.7': Closing #17378: ctypes documentation fix. http://hg.python.org/cpython/rev/2dd77a12e7bf |
|||
| History | |||
|---|---|---|---|
| Date | User | Action | Args |
| 2022年04月11日 14:57:42 | admin | set | github: 61580 |
| 2013年03月08日 13:35:50 | python-dev | set | status: open -> closed resolution: fixed messages: + msg183735 stage: needs patch -> resolved |
| 2013年03月08日 13:33:58 | python-dev | set | nosy:
+ python-dev messages: + msg183734 |
| 2013年03月07日 15:06:56 | theller | set | messages: + msg183668 |
| 2013年03月07日 14:09:38 | eli.bendersky | set | nosy:
+ theller, amaury.forgeotdarc |
| 2013年03月07日 14:09:12 | eli.bendersky | set | files:
+ issue17378.1.patch keywords: + patch messages: + msg183663 |
| 2013年03月07日 13:58:47 | eli.bendersky | create | |