@@ -35,7 +35,7 @@ def add_dll_directory(dll_abs_path: str) -> None:
35
35
os .environ ["PATH" ] = dirpath if curr_path is None else os .pathsep .join ((curr_path , dirpath ))
36
36
37
37
38
- def abs_path_for_dynamic_library (handle : int ) -> str :
38
+ def abs_path_for_dynamic_library (libname : str , handle : int ) -> str :
39
39
"""Get the absolute path of a loaded dynamic library on Windows.
40
40
41
41
Args:
@@ -57,7 +57,8 @@ def abs_path_for_dynamic_library(handle: int) -> str:
57
57
58
58
if n_chars == 0 :
59
59
raise OSError (
60
- "GetModuleFileNameW failed. Long paths may require enabling the "
60
+ f"GetModuleFileNameW failed ({ libname = !r} , { buf_size = } ). "
61
+ "Long paths may require enabling the "
61
62
"Windows 10+ long path registry setting. See: "
62
63
"https://docs.python.org/3/using/windows.html#removing-the-max-path-limitation"
63
64
)
@@ -99,7 +100,7 @@ def check_if_already_loaded_from_elsewhere(libname: str) -> Optional[LoadedDL]:
99
100
except pywintypes .error :
100
101
continue
101
102
else :
102
- return LoadedDL (handle , abs_path_for_dynamic_library (handle ), True )
103
+ return LoadedDL (handle , abs_path_for_dynamic_library (libname , handle ), True )
103
104
return None
104
105
105
106
@@ -118,7 +119,7 @@ def load_with_system_search(libname: str, _unused: str) -> Optional[LoadedDL]:
118
119
for dll_name in SUPPORTED_WINDOWS_DLLS .get (libname , ()):
119
120
handle = ctypes .windll .kernel32 .LoadLibraryW (ctypes .c_wchar_p (dll_name ))
120
121
if handle :
121
- return LoadedDL (handle , abs_path_for_dynamic_library (handle ), False )
122
+ return LoadedDL (handle , abs_path_for_dynamic_library (libname , handle ), False )
122
123
123
124
return None
124
125
0 commit comments