Steve Dower <steve.do...@python.org> added the comment:

add_dll_directory can be safely used within your library, so if you have any 
.py files that will be imported first (such as your package __init__.py), you 
can add it then. The safest way is to use something like:

with os.add_dll_directory(THE_DIR):
    import the_module

As this won't leave your directory on the search path for anyone else's DLLs.

The most correct fix is to put your DLL alongside your .pyd file. But I suspect 
in your case, the DLLs can't be moved, so using the search directory is likely 
best. (Or you could put your .pyd with the DLLs and update sys.path for when 
you import it.)

Presumably in the past, you were relying on the DLLs being on the user's PATH, 
which makes your application vulnerable to DLL hijacking (malicious or 
accidental, we've seen both). Not having to worry about that is a good thing.

----------

_______________________________________
Python tracker <rep...@bugs.python.org>
<https://bugs.python.org/issue40906>
_______________________________________
_______________________________________________
Python-bugs-list mailing list
Unsubscribe: 
https://mail.python.org/mailman/options/python-bugs-list/archive%40mail-archive.com

Reply via email to