New submission from Christian Heimes: errno is usually implemented as thread local variable, more precisely as a macro that calls a function which returns the memory address of a thread local variable. Each C runtime library has its own function and TLS which introduces an issue when a Python extension uses a different CRT than the core. AFAIK that an issue only an issue on Windows with other versions of Visual Studio.
This means that mixed CRTs break the three PyErr_SetFromErrno* functions as they always access the errno of the core's CRT. The patch adds a Py_errno macro that must be used in extensions before a PyErr_SetFromErrno() function is used. Example: fd = open(filename, O_RDONLY); if (fd == -1) { Py_errno = errno; return PyErr_SetFromErrnoWithFilename(PyExc_OSError, filename); } The issue was discovered by me a about two weeks ago and further analyzed by Martin. http://mail.python.org/pipermail/python-dev/2012-August/121460.html ---------- components: Build, Extension Modules, Interpreter Core files: pyerrno.patch keywords: patch messages: 170050 nosy: christian.heimes, georg.brandl, loewis, pitrou priority: normal severity: normal stage: patch review status: open title: Add Py_errno to work around multiple CRT issue type: behavior versions: Python 3.3, Python 3.4 Added file: http://bugs.python.org/file27148/pyerrno.patch _______________________________________ Python tracker <rep...@bugs.python.org> <http://bugs.python.org/issue15883> _______________________________________ _______________________________________________ Python-bugs-list mailing list Unsubscribe: http://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com