Index: posixmodule.c =================================================================== --- posixmodule.c (revision 84114) +++ posixmodule.c (working copy) @@ -1109,7 +1109,7 @@ } /* Grab GetFinalPathNameByHandle dynamically from kernel32 */ -static int has_GetFinalPathNameByHandle = 0; +static int has_GetFinalPathNameByHandle = -1; static DWORD (CALLBACK *Py_GetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD, DWORD); static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD, @@ -1117,11 +1117,10 @@ static int check_GetFinalPathNameByHandle() { - HINSTANCE hKernel32; - /* only recheck */ - if (!has_GetFinalPathNameByHandle) + /* only check once */ + if (has_GetFinalPathNameByHandle < 0) { - hKernel32 = GetModuleHandle("KERNEL32"); + HINSTANCE hKernel32 = GetModuleHandle("KERNEL32"); *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32, "GetFinalPathNameByHandleA"); *(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,