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.

Author theller
Recipients amaury.forgeotdarc, arigo, fijal, loewis, theller
Date 2008-05-29.18:56:58
SpamBayes Score 0.006978461
Marked as misclassified No
Message-id <>
In-reply-to <>
Ok, here is the plan (basically Armin's proposal):

ctypes maintains a gloabl, but thread-local, variable that contains an error number;
called 'ctypes_errno' for this discussion.

ctypes.set_errno(value) copies 'value' into ctypes_errno, and returns the old value.
ctypes.get_errno() returns the current ctypes_errno value.

Foreign functions created with CDLL(..., use_errno=True), when called, copy
the ctypes_errno value into the real errno just before they are called, and copy
the real errno value into ctypes_errno. The 'use_errno' parameter defaults to False,
in this case ctypes_errno is not touched.

The same scheme is implemented on Windows for GetLastError() and SetLastError(),
the variable is named 'ctypes_LastError', and the CDLL and WinDLL optional parameter
is named 'use_LastError', and also defaults to False.

Armin Rigo schrieb:
> (Another note: the C-level errno and the TLS copy should also be
> synchronized when the C code invokes a Python callback.)

Not sure what this is for, please proofread the patch when I attach one.
Even better, someone could supply test-cases for all this, either
as executable code or as prosa.

> (A related issue that we may or may not care about: it's more than
> likely that various people have already come up with various workarounds
> to handle errno, and these workarounds will probably stop working after
> ctypes is changed...)

Since the new behaviour will only be invoked when use_errno or use_LastError
is used, they should be able to still use their workarounds.
Date User Action Args
2008-05-29 18:57:00thellersetspambayes_score: 0.00697846 -> 0.006978461
recipients: + theller, loewis, arigo, amaury.forgeotdarc, fijal
2008-05-29 18:56:59thellerlinkissue1798 messages
2008-05-29 18:56:58thellercreate