]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374)
authorJeffrey Kintscher <49998481+websurfer5@users.noreply.github.com>
Mon, 1 Jan 2024 16:24:24 +0000 (08:24 -0800)
committerGitHub <noreply@github.com>
Mon, 1 Jan 2024 16:24:24 +0000 (18:24 +0200)
commit5f3cc90a12d6df404fd6f48a0df1334902e271f2
treeb0939a5ee6d6b2477179fc74f31fe854fcc57091
parent4036e48d59b0f9e8057e01458ab7df3dfd323a10
gh-62260: Fix ctypes.Structure subclassing with multiple layers (GH-13374)

The length field of StgDictObject for Structure class contains now
the total number of items in ffi_type_pointer.elements (excluding
the trailing null).

The old behavior of using the number of elements in the parent class can
cause the array to be truncated when it is copied, especially when there
are multiple layers of subclassing.

Co-authored-by: Serhiy Storchaka <storchaka@gmail.com>
Lib/test/test_ctypes/test_structures.py
Misc/NEWS.d/next/Library/2019-05-17-07-22-33.bpo-18060.5mqTQM.rst [new file with mode: 0644]
Modules/_ctypes/_ctypes.c
Modules/_ctypes/stgdict.c