@@ -35,7 +35,7 @@ def add_dll_directory(dll_abs_path: str) -> None:
3535 os .environ ["PATH" ] = dirpath if curr_path is None else os .pathsep .join ((curr_path , dirpath ))
3636
3737
38- def abs_path_for_dynamic_library (handle : int ) -> str :
38+ def abs_path_for_dynamic_library (libname : str , handle : int ) -> str :
3939 """Get the absolute path of a loaded dynamic library on Windows.
4040
4141 Args:
@@ -57,7 +57,8 @@ def abs_path_for_dynamic_library(handle: int) -> str:
5757
5858 if n_chars == 0 :
5959 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 "
6162 "Windows 10+ long path registry setting. See: "
6263 "https://docs.python.org/3/using/windows.html#removing-the-max-path-limitation"
6364 )
@@ -99,7 +100,7 @@ def check_if_already_loaded_from_elsewhere(libname: str) -> Optional[LoadedDL]:
99100 except pywintypes .error :
100101 continue
101102 else :
102- return LoadedDL (handle , abs_path_for_dynamic_library (handle ), True )
103+ return LoadedDL (handle , abs_path_for_dynamic_library (libname , handle ), True )
103104 return None
104105
105106
@@ -118,7 +119,7 @@ def load_with_system_search(libname: str, _unused: str) -> Optional[LoadedDL]:
118119 for dll_name in SUPPORTED_WINDOWS_DLLS .get (libname , ()):
119120 handle = ctypes .windll .kernel32 .LoadLibraryW (ctypes .c_wchar_p (dll_name ))
120121 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 )
122123
123124 return None
124125
0 commit comments