[Python-checkins] cpython: Closes #9445: Removes detection of GetFinalPathNameByHandle

steve.dower python-checkins at python.org
Wed Mar 25 07:36:56 CET 2015


https://hg.python.org/cpython/rev/d094eeeb1496
changeset: 95198:d094eeeb1496
user: Steve Dower <steve.dower at microsoft.com>
date: Fri Mar 20 21:49:12 2015 -0700
summary:
 Closes #9445: Removes detection of GetFinalPathNameByHandle
files:
 Modules/posixmodule.c | 56 +++---------------------------
 1 files changed, 6 insertions(+), 50 deletions(-)
diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c
--- a/Modules/posixmodule.c
+++ b/Modules/posixmodule.c
@@ -1437,31 +1437,6 @@
 return TRUE;
 }
 
-/* Grab GetFinalPathNameByHandle dynamically from kernel32 */
-static int has_GetFinalPathNameByHandle = -1;
-static DWORD (CALLBACK *Py_GetFinalPathNameByHandleW)(HANDLE, LPWSTR, DWORD,
- DWORD);
-static int
-check_GetFinalPathNameByHandle()
-{
- HINSTANCE hKernel32;
- DWORD (CALLBACK *Py_GetFinalPathNameByHandleA)(HANDLE, LPSTR, DWORD,
- DWORD);
-
- /* only recheck */
- if (-1 == has_GetFinalPathNameByHandle)
- {
- hKernel32 = GetModuleHandleW(L"KERNEL32");
- *(FARPROC*)&Py_GetFinalPathNameByHandleA = GetProcAddress(hKernel32,
- "GetFinalPathNameByHandleA");
- *(FARPROC*)&Py_GetFinalPathNameByHandleW = GetProcAddress(hKernel32,
- "GetFinalPathNameByHandleW");
- has_GetFinalPathNameByHandle = Py_GetFinalPathNameByHandleA &&
- Py_GetFinalPathNameByHandleW;
- }
- return has_GetFinalPathNameByHandle;
-}
-
 static BOOL
 get_target_path(HANDLE hdl, wchar_t **target_path)
 {
@@ -1470,8 +1445,8 @@
 
 /* We have a good handle to the target, use it to determine
 the target path name (then we'll call lstat on it). */
- buf_size = Py_GetFinalPathNameByHandleW(hdl, 0, 0,
- VOLUME_NAME_DOS);
+ buf_size = GetFinalPathNameByHandleW(hdl, 0, 0,
+ VOLUME_NAME_DOS);
 if(!buf_size)
 return FALSE;
 
@@ -1481,7 +1456,7 @@
 return FALSE;
 }
 
- result_length = Py_GetFinalPathNameByHandleW(hdl,
+ result_length = GetFinalPathNameByHandleW(hdl,
 buf, buf_size, VOLUME_NAME_DOS);
 
 if(!result_length) {
@@ -1514,12 +1489,6 @@
 wchar_t *target_path;
 const char *dot;
 
- if(!check_GetFinalPathNameByHandle()) {
- /* If the OS doesn't have GetFinalPathNameByHandle, don't
- traverse reparse point. */
- traverse = FALSE;
- }
-
 hFile = CreateFileA(
 path,
 FILE_READ_ATTRIBUTES, /* desired access */
@@ -1610,12 +1579,6 @@
 wchar_t *target_path;
 const wchar_t *dot;
 
- if(!check_GetFinalPathNameByHandle()) {
- /* If the OS doesn't have GetFinalPathNameByHandle, don't
- traverse reparse point. */
- traverse = FALSE;
- }
-
 hFile = CreateFileW(
 path,
 FILE_READ_ATTRIBUTES, /* desired access */
@@ -4700,13 +4663,6 @@
 if (path_wchar == NULL)
 return NULL;
 
- if(!check_GetFinalPathNameByHandle()) {
- /* If the OS doesn't have GetFinalPathNameByHandle, return a
- NotImplementedError. */
- return PyErr_Format(PyExc_NotImplementedError,
- "GetFinalPathNameByHandle not available on this platform");
- }
-
 hFile = CreateFileW(
 path_wchar,
 0, /* desired access */
@@ -4722,7 +4678,7 @@
 
 /* We have a good handle to the target, use it to determine the
 target path name. */
- buf_size = Py_GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_NT);
+ buf_size = GetFinalPathNameByHandleW(hFile, 0, 0, VOLUME_NAME_NT);
 
 if(!buf_size)
 return win32_error_object("GetFinalPathNameByHandle", path);
@@ -4731,8 +4687,8 @@
 if(!target_path)
 return PyErr_NoMemory();
 
- result_length = Py_GetFinalPathNameByHandleW(hFile, target_path,
- buf_size, VOLUME_NAME_DOS);
+ result_length = GetFinalPathNameByHandleW(hFile, target_path,
+ buf_size, VOLUME_NAME_DOS);
 if(!result_length)
 return win32_error_object("GetFinalPathNamyByHandle", path);
 
-- 
Repository URL: https://hg.python.org/cpython


More information about the Python-checkins mailing list

AltStyle によって変換されたページ (->オリジナル) /