Index: Python/thread_nt.h =================================================================== --- Python/thread_nt.h (revision 68465) +++ Python/thread_nt.h (working copy) @@ -315,7 +315,10 @@ void * PyThread_get_key_value(int key) { - return TlsGetValue(key); + DWORD error = GetLastError(); + LPVOID res = TlsGetValue(key); + SetLastError(error); + return res; } void