Eryk Sun <[email protected]> added the comment:
> it seems the search order we're getting for _sqlite3.dll (.pyd) is:
>
> * app directory
> * SQL server install directory (?)
> * Windows/System32
> * Windows
> * %PATH% (which is truncated at 2190 chars)
Thank you. It finally makes sense. The parent process is calling
SetDllDirectoryW [1], which also replaces the current working directory in the
DLL search path of child processes (inherited via the PEB
ProcessParameters->DllPath) [2]:
Note: The standard search order of the process will also be
affected by calling the SetDllDirectory function in the parent
process before start of the current process.
In that case, all we have to do is restore the original search path by calling
SetDllDirectoryW(NULL). For example:
import ctypes
kernel32 = ctypes.WinDLL('kernel32', use_last_error=True)
if not kernel32.SetDllDirectoryW(None):
raise ctypes.WinError(ctypes.get_last_error())
[1]:
https://docs.microsoft.com/en-us/windows/win32/api/winbase/nf-winbase-setdlldirectoryw
[2]:
https://docs.microsoft.com/en-us/windows/win32/dlls/dynamic-link-library-search-order#alternate-search-order-for-desktop-applications
----------
_______________________________________
Python tracker <[email protected]>
<https://bugs.python.org/issue40214>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe:
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com