Joseph Fox-Rabinovitz <jfoxrabinov...@gmail.com> added the comment:

Last attempt before I give up:

ctypes.CDLL initializer defined in version 3.8 and beyond as

```
def __init__(self, name, mode=DEFAULT_MODE, handle=None,
             use_errno=False,
             use_last_error=False,
             winmode=None):
```

Documentation says `winmode=0`:

```
class ctypes.CDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, 
use_last_error=False, winmode=0)
```

Loading of normal DLL from custom directory works when `winmode=0`, but not 
when `winmode=None`. To reproduce, any combination of adding the folder 
containing the DLL via `os.eviron['PATH'] += os.pathsep + ...`, 
`os.add_dll_directory(...)`, `sys.path.append(...)` does not change the 
behavior.

Worked prior to 3.8 because there was no `winmode` parameter, `mode` was passed 
in diretly, and `ctypes.DEFAULT_MODE == 0`.

I don't know whether it's better to update the code, the docs, or something 
else, but based on current info, would prefer updating the code.

Discovery triggered by https://stackoverflow.com/q/59330863/2988730.
Some info summarized in https://stackoverflow.com/a/64472088/2988730.

Link to docs: https://docs.python.org/3.{8,9,10}/library/ctypes.html#ctypes.CDLL
Link to GitHub code: 
https://github.com/python/cpython/blob/3.{8,9}/Lib/ctypes/__init__.py#L340

----------

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

Reply via email to