Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 2ee91c8

Browse files
authored
[3.6] bpo-30470: Deprecate invalid ctypes call protection on Windows. (GH-1810) (GH-1833)
Calling Ctypes functions is deprecated in 3.6.2 and will be removed in 3.7. (cherry picked from commit f931fd1)
1 parent 94d8261 commit 2ee91c8

1 file changed

Lines changed: 6 additions & 14 deletions

File tree

Doc/library/ctypes.rst

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -161,22 +161,14 @@ as the NULL pointer)::
161161
0x1d000000
162162
>>>
163163

164-
:mod:`ctypes` tries to protect you from calling functions with the wrong number
165-
of arguments or the wrong calling convention. Unfortunately this only works on
166-
Windows. It does this by examining the stack after the function returns, so
167-
although an error is raised the function *has* been called::
164+
.. note::
168165

169-
>>> windll.kernel32.GetModuleHandleA() # doctest: +WINDOWS
170-
Traceback (most recent call last):
171-
File "<stdin>", line 1, in <module>
172-
ValueError: Procedure probably called with not enough arguments (4 bytes missing)
173-
>>> windll.kernel32.GetModuleHandleA(0, 0) # doctest: +WINDOWS
174-
Traceback (most recent call last):
175-
File "<stdin>", line 1, in <module>
176-
ValueError: Procedure probably called with too many arguments (4 bytes in excess)
177-
>>>
166+
:mod:`ctypes` may raise a :exc:`ValueError` after calling the function, if
167+
it detects that an invalid number of arguments were passed. This behavior
168+
should not be relied upon. It is deprecated in 3.6.2, and will be removed
169+
in 3.7.
178170

179-
The same exception is raised when you call an ``stdcall`` function with the
171+
:exc:`ValueError` is raised when you call an ``stdcall`` function with the
180172
``cdecl`` calling convention, or vice versa::
181173

182174
>>> cdll.kernel32.GetModuleHandleA(None) # doctest: +WINDOWS

0 commit comments

Comments
 (0)