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.

classification
Title: CTypes _as_parameter_ not working as documented
Type: Stage:
Components: None Versions: Python 2.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: shane_holloway, theller
Priority: normal Keywords:

Created on 2006-08-02 22:11 by shane_holloway, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
from_param.patch shane_holloway, 2006-08-02 22:11 Patch implementing _as_parameter_ as documented
Messages (3)
msg29429 - (view) Author: Shane Holloway (shane_holloway) Date: 2006-08-02 22:11
Reference: http://docs.python.org/dev/lib/ctypes-calling-functions-
with-own-custom-data-types.html

According to this document, I should be able to use my own objects with 
ctypes, provided I have an _as_parameter_ attribute set on my object.  
However, this does not work properly when the foreign function's 
argtypes have been set.  

This is because the _as_parameter_ access is not done until after the 
argument types are checked.  

Attached is a patch that adds _as_parameter_ checking to the types 
provided by _ctypes.c so that the feature works as documented for both 
typed and untyped foreign functions.
(Patch is against: svn rev 50859)
msg29430 - (view) Author: Shane Holloway (shane_holloway) Date: 2006-08-02 22:13
Logged In: YES 
user_id=283742

A related patch is http://python.org/sf/1532975 that simplifies the 
implementation of _as_parameter_
msg29431 - (view) Author: Thomas Heller (theller) * (Python committer) Date: 2006-08-14 14:21
Logged In: YES 
user_id=11105

The patch in http://python.org/sf/1532975 was committed
together with the general idea of this patch as SVN revision
51277.
History
Date User Action Args
2022-04-11 14:56:19adminsetgithub: 43763
2006-08-02 22:11:49shane_hollowaycreate