Message59748
This patch adds new calling conventions to ctypes foreign functions by
passing 'errno=True' or 'GetLastError=True' to the CDLL or WinDLL
constructor.
If CDLL(..., errno=True) or WinDLL(..., errno=True) is used, the
function objects available in the CDLL or WinDLL instance will set the C
global errno to zero before the actual call, and attach the C global
errno value after the call as 'errno' attribute to the function object.
This attribute is stored in thread-local storage.
Similarly, if CDLL(..., GetLastError=True) or WinDLL(...,
GetLastError=True) is used, the win32 api function 'SetLastError(0)' is
used to reset the windows last error code before the actual call, and
the value returned by 'GetLastError()' is attached as 'LastError'
attribute to the function object, in thread local storage. Of course
this only occurs on Windows.
The LastError and errno attributes are readonly from Python code,
accessing them before a foreign function call has occurred in the
current thread raises a ValueError. |
|
| Date |
User |
Action |
Args |
| 2008-01-11 20:51:37 | theller | set | spambayes_score: 0.00795397 -> 0.00795397 recipients:
+ theller |
| 2008-01-11 20:51:37 | theller | set | spambayes_score: 0.00795397 -> 0.00795397 messageid: <1200084697.63.0.170138698691.issue1798@psf.upfronthosting.co.za> |
| 2008-01-11 20:51:36 | theller | link | issue1798 messages |
| 2008-01-11 20:51:36 | theller | create | |
|