This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Documentation of ctypes.CDLL does not correspond to code
Type: Stage: resolved
Components: Documentation Versions: Python 3.11, Python 3.10, Python 3.9
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: docs@python Nosy List: docs@python, lukasz.langa, madphysicist, miss-islington, sbraz
Priority: normal Keywords: patch

Created on 2020-10-21 22:02 by madphysicist, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 29976 merged sbraz, 2021-12-08 00:20
PR 30037 merged miss-islington, 2021-12-10 23:00
PR 30038 merged miss-islington, 2021-12-10 23:00
Messages (7)
msg379261 - (view) Author: Joseph Fox-Rabinovitz (madphysicist) * Date: 2020-10-21 22:02
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 when `winmode=None` To reproduce, any combination of adding the fol += der containing the DLL to `os.evia ron['PATH']`, `os.add_dll_directory(...)`

Discoveryos.pathsep + ... triggered by https://stackoverflow.co, `sys.path.appen

Worked prior to 3.8 because there was no `winmode` parameter, and d(...)` does not change the behavior.m/q/`mode` was passed in directly, 59330863/298873`ctypes0. .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.Some info summarized in https://stackoverflow.com/a/{8,9,}64472088/2988730.

Link to do pagecscorresponding : https://docs.python.org/3.10/library/ctypes.html#ctypes.CDLL
730.
Link to GitHub code: https://github.com/python/cpython/blob/3.{8,9}/Lib/ctypes/__init__.py#L340
msg379262 - (view) Author: Joseph Fox-Rabinovitz (madphysicist) * Date: 2020-10-21 22:10
Company firewall mutilated the text. Here is another attempt:

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 `parameter, and `mode` was passed in direcCompany firewall mutilated the text. Here is another attempt:

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.

yink 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#L340t.ly, `ctyp. .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.

yink 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
msg379263 - (view) Author: Joseph Fox-Rabinovitz (madphysicist) * Date: 2020-10-21 22:12
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
msg408252 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-12-10 23:00
New changeset c1051e08b3c6d9045322763876a4b0aea98d79f9 by Louis Sautier in branch 'main':
bpo-42114: ctypes documentation: fix winmode parameter default value (GH-29976)
https://github.com/python/cpython/commit/c1051e08b3c6d9045322763876a4b0aea98d79f9
msg408263 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-12-10 23:29
New changeset f8eebb0db720cd81fb736d9cbfd16faf2ec68b53 by Miss Islington (bot) in branch '3.9':
bpo-42114: ctypes documentation: fix winmode parameter default value (GH-29976) (GH-30038)
https://github.com/python/cpython/commit/f8eebb0db720cd81fb736d9cbfd16faf2ec68b53
msg408264 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-12-10 23:29
New changeset 8f3728edcbc205913772f8dc04cccd8bdc476ff4 by Miss Islington (bot) in branch '3.10':
bpo-42114: ctypes documentation: fix winmode parameter default value (GH-29976) (GH-30037)
https://github.com/python/cpython/commit/8f3728edcbc205913772f8dc04cccd8bdc476ff4
msg408265 - (view) Author: Łukasz Langa (lukasz.langa) * (Python committer) Date: 2021-12-10 23:30
Thanks! ✨ 🍰 ✨
History
Date User Action Args
2022-04-11 14:59:37adminsetgithub: 86280
2021-12-10 23:30:28lukasz.langasetstatus: open -> closed

assignee: docs@python
components: + Documentation, - ctypes
versions: + Python 3.11, - Python 3.8
nosy: + docs@python

messages: + msg408265
resolution: fixed
stage: patch review -> resolved
2021-12-10 23:29:50lukasz.langasetmessages: + msg408264
2021-12-10 23:29:38lukasz.langasetmessages: + msg408263
2021-12-10 23:00:51miss-islingtonsetpull_requests: + pull_request28264
2021-12-10 23:00:44miss-islingtonsetnosy: + miss-islington
pull_requests: + pull_request28263
2021-12-10 23:00:24lukasz.langasetnosy: + lukasz.langa
messages: + msg408252
2021-12-08 00:20:40sbrazsetkeywords: + patch
nosy: + sbraz

pull_requests: + pull_request28202
stage: patch review
2020-10-21 22:12:43madphysicistsetmessages: + msg379263
2020-10-21 22:10:45madphysicistsetmessages: + msg379262
2020-10-21 22:02:35madphysicistsettitle: Documentation of -> Documentation of ctypes.CDLL does not correspond to code
2020-10-21 22:02:15madphysicistcreate