Description
Bug report
Bug description:
os.add_dll_directory's documentation states that "This search path is used when resolving dependencies for imported extension modules (the module itself is resolved through sys.path), and also by ctypes.", yet paths added there do not affect ctypes.util.find_library (one can easily verify that the implementation of the latter simply walks PATH:
Lines 55 to 68 in b4c215e
I do realize that find_library's doc does state "The purpose of the find_library() function is to locate a library in a way similar to what the compiler or runtime loader does (on platforms with several versions of a shared library the most recent should be loaded), while the ctypes library loaders act like when a program is run, and call the runtime loader directly." which might justify the difference in behavior; still, it would be nice if ctypes provided a function (or changed find_library) to return the path of the library that would be loaded while respecting add_dll_directory (right now a workaround would be to call GetModuleFileNameEx ourselves on the handle returned by WinDLL).
CPython versions tested on:
3.12
Operating systems tested on:
Windows