Currently on Windows, Py_END_ALLOW_THREADS can have the side effect of 
resetting the windows error code returned by GetLastError().
There is a number of cases, particularly in posixmodule, with a pattern like:
Py_BEGIN_ALLOW_THREADS
            result = FindNextFile(hFindFile, &FileData);
            Py_END_ALLOW_THREADS
            /* FindNextFile sets error to ERROR_NO_MORE_FILES if
               it got to the end of the directory. */
            if (!result && GetLastError() != ERROR_NO_MORE_FILES) {

That doesn´t work.  (This particular site is where I noticed the problem, 
running the testsuite in a debug build).
Now, the thread swith macro does take care to preserve "errno", but not the 
windows system error.  This is easy to add, but it requires that windows.h be 
included by ceval.c and pystate.c
The alternative fix is to find all these cases and manually preserve the error 
state, or query it right after the function call if needed.
Any preferences?

Kristján

_______________________________________________
Python-Dev mailing list
Python-Dev@python.org
http://mail.python.org/mailman/listinfo/python-dev
Unsubscribe: 
http://mail.python.org/mailman/options/python-dev/archive%40mail-archive.com

Reply via email to