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 arigo
Recipients amaury.forgeotdarc, arigo, fijal, loewis, theller
Date 2008-05-24.07:58:15
SpamBayes Score 0.00434184
Marked as misclassified No
Message-id <>
> However, even the TLS copy of errno may change because of this,
> if the finalizer of some object invokes ctypes, right?

Yes, it's annoying, but at least the Python programmer has a way to fix
this problem: he can save and restore the TLS copy of errno around the
call to ctypes done in the finalizer, using get_errno()/set_errno(). 
This matches what a C programmer would have to do if he wanted to write,
say, a debugging function that can be called from anywhere including
between an OS call and the following check for errno.

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

In PyPy, when creating and using our own internal FFI, we started by
having a pair of functions that could directly read or change the
C-level errno.  Then we ran into various troubles (e.g. just stepping
through the Python code in a debugger messes things up because of the
debugger's own input/output) and finally reached the design I propose
here.  (Admittedly PyPy's internal FFI is a bit more low-level than
ctypes, so maybe it's more appropriate for ctypes to use a higher-level
approach that a return value checker.)

(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...)
Date User Action Args
2008-05-24 07:58:57arigosetspambayes_score: 0.00434184 -> 0.00434184
recipients: + arigo, loewis, theller, amaury.forgeotdarc, fijal
2008-05-24 07:58:56arigosetspambayes_score: 0.00434184 -> 0.00434184
messageid: <>
2008-05-24 07:58:54arigolinkissue1798 messages
2008-05-24 07:58:47arigocreate