[issue1798] Add ctypes calling convention that allows safe access of errno

Martin v. Löwis report at bugs.python.org
Fri May 23 19:31:11 CEST 2008


Martin v. Löwis <martin at v.loewis.de> added the comment:

>> How can Python run arbitrary code between the return from a ctypes
>> method and the next Python instruction? None of the code should have any
>> effect on errno.
> 
> By freeing objects because their refcount has reached zero?

No, that should not set errno. Free cannot fail, and will not modify
errno. Try running

#include <errno.h>
int main()
{
    errno = 117;
    free(malloc(100));
    printf("%d\n", errno);
}

malloc might set errno, but only if it fails (in which case you'll get
a Python exception, anyway).

__________________________________
Tracker <report at bugs.python.org>
<http://bugs.python.org/issue1798>
__________________________________


More information about the Python-bugs-list mailing list