]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-46323: _ctypes.CFuncPtr fails if _argtypes_ is too long (GH-31188)
authorVictor Stinner <vstinner@python.org>
Mon, 7 Feb 2022 13:53:15 +0000 (14:53 +0100)
committerGitHub <noreply@github.com>
Mon, 7 Feb 2022 13:53:15 +0000 (14:53 +0100)
commit4cce1352bb47babaeefb68fcfcc48ffa073745c3
tree0b920e214dc1ddbb8d796de50cf93ba99ae3bc3f
parent8e98175a03fe03d62822d96007a74e5273013764
bpo-46323: _ctypes.CFuncPtr fails if _argtypes_ is too long (GH-31188)

ctypes.CFUNCTYPE() and ctypes.WINFUNCTYPE() now fail to create the
type if its "_argtypes_" member contains too many arguments.
Previously, the error was only raised when calling a function.

Change also how CFUNCTYPE() and WINFUNCTYPE() handle KeyError to
prevent creating a chain of exceptions if ctypes.CFuncPtr raises an
error.
Lib/ctypes/__init__.py
Lib/ctypes/test/test_callbacks.py
Misc/NEWS.d/next/Library/2022-02-07-13-27-59.bpo-46323.7UENAj.rst [new file with mode: 0644]
Modules/_ctypes/_ctypes.c
Modules/_ctypes/callproc.c
Modules/_ctypes/ctypes.h