From 089470d3e09bc47a95206e3d9a821ccca33fbf7b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Wed, 25 Mar 2020 20:01:57 +0000 Subject: [PATCH 1/3] doc: fix documented winmode argument default in ctypes CDLL classes. The default value for the `winmode` argument in the ctypes CDLL, OleDll, and WinDLL classes is `None` and not `0` and these have different behaviours. `None` means ctypes default of LOAD_LIBRARY_SEARCH_DEFAULT_DIRS | LOAD_LIBRARY_SEARCH_DLL_LOAD_DIR while `0` means no LOAD_LIBRARY_SEARCH flag which defaults to Windows `LoadLibrary` behaviour. --- Doc/library/ctypes.rst | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 2d6c6d0a1c3c57..7e673c26bf0be3 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1320,14 +1320,14 @@ There are several ways to load shared libraries into the Python process. One way is to instantiate one of the following classes: -.. class:: CDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=0) +.. class:: CDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None) Instances of this class represent loaded shared libraries. Functions in these libraries use the standard C calling convention, and are assumed to return :c:type:`int`. -.. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=0) +.. class:: OleDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None) Windows only: Instances of this class represent loaded shared libraries, functions in these libraries use the ``stdcall`` calling convention, and are @@ -1340,7 +1340,7 @@ way is to instantiate one of the following classes: :exc:`WindowsError` used to be raised. -.. class:: WinDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=0) +.. class:: WinDLL(name, mode=DEFAULT_MODE, handle=None, use_errno=False, use_last_error=False, winmode=None) Windows only: Instances of this class represent loaded shared libraries, functions in these libraries use the ``stdcall`` calling convention, and are @@ -1394,8 +1394,8 @@ copy of the windows error code. The *winmode* parameter is used on Windows to specify how the library is loaded (since *mode* is ignored). It takes any value that is valid for the Win32 API -``LoadLibraryEx`` flags parameter. When omitted, the default is to use the flags -that result in the most secure DLL load to avoiding issues such as DLL +``LoadLibraryEx`` flags parameter. When it is ``None``, the default is to use +the flags that result in the most secure DLL load to avoiding issues such as DLL hijacking. Passing the full path to the DLL is the safest way to ensure the correct library and dependencies are loaded. From 306606a2fa723915505d36a2c06306139a19f2bb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Carn=C3=AB=20Draug?= Date: Sat, 28 Mar 2020 12:41:21 +0000 Subject: [PATCH 2/3] doc: improve english writing --- Doc/library/ctypes.rst | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index 7e673c26bf0be3..281f0f47a9889a 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1395,9 +1395,9 @@ copy of the windows error code. The *winmode* parameter is used on Windows to specify how the library is loaded (since *mode* is ignored). It takes any value that is valid for the Win32 API ``LoadLibraryEx`` flags parameter. When it is ``None``, the default is to use -the flags that result in the most secure DLL load to avoiding issues such as DLL -hijacking. Passing the full path to the DLL is the safest way to ensure the -correct library and dependencies are loaded. +the flags that result in the most secure DLL load in order to avoid issues such +as DLL hijacking. Passing the full path to the DLL is the safest way to ensure +the correct library and dependencies are loaded. .. versionchanged:: 3.8 Added *winmode* parameter. From 95992c7aabebdd02dab2c7f02bb80128e4fdf5fd Mon Sep 17 00:00:00 2001 From: David Miguel Susano Pinto Date: Mon, 28 Nov 2022 11:32:33 +0000 Subject: [PATCH 3/3] doc: minor english improvement in Doc/Library/ctypes.rst Co-authored-by: Eryk Sun --- Doc/library/ctypes.rst | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Doc/library/ctypes.rst b/Doc/library/ctypes.rst index f41f42fa7dbfb4..fd5df875ed74d5 100644 --- a/Doc/library/ctypes.rst +++ b/Doc/library/ctypes.rst @@ -1440,10 +1440,10 @@ copy of the windows error code. The *winmode* parameter is used on Windows to specify how the library is loaded (since *mode* is ignored). It takes any value that is valid for the Win32 API -``LoadLibraryEx`` flags parameter. When it is ``None``, the default is to use -the flags that result in the most secure DLL load in order to avoid issues such -as DLL hijacking. Passing the full path to the DLL is the safest way to ensure -the correct library and dependencies are loaded. +``LoadLibraryEx`` flags parameter. When omitted, the default is to use the +flags that result in the most secure DLL load, which avoids issues such as DLL +hijacking. Passing the full path to the DLL is the safest way to ensure the +correct library and dependencies are loaded. .. versionchanged:: 3.8 Added *winmode* parameter.