Message67285
> 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:57 | arigo | set | spambayes_score: 0.00434184 -> 0.0043418384 recipients:
+ arigo, loewis, theller, amaury.forgeotdarc, fijal |
2008-05-24 07:58:56 | arigo | set | spambayes_score: 0.00434184 -> 0.00434184 messageid: <1211615936.19.0.658697602591.issue1798@psf.upfronthosting.co.za> |
2008-05-24 07:58:54 | arigo | link | issue1798 messages |
2008-05-24 07:58:47 | arigo | create | |
|