]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
[3.14] gh-148967: Fix FFI type pointer handling for C complex support in set_stginfo_...
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 1 May 2026 13:43:38 +0000 (15:43 +0200)
committerGitHub <noreply@github.com>
Fri, 1 May 2026 13:43:38 +0000 (15:43 +0200)
(cherry picked from commit f2c7c0d2b799c927d9a78e87e4a640d3f9b0356c)

Co-authored-by: sunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Modules/_ctypes/_ctypes.c

index 705aac896aab4e29eada30ae0d429936d56a1192..eb1e70c9afdf0f3660ae6ce32cda755f8a146f00 100644 (file)
@@ -2235,6 +2235,7 @@ c_void_p_from_param_impl(PyObject *type, PyTypeObject *cls, PyObject *value)
 static int
 set_stginfo_ffi_type_pointer(StgInfo *stginfo, struct fielddesc *fmt)
 {
+#if defined(_Py_FFI_SUPPORT_C_COMPLEX)
     if (!fmt->pffi_type->elements) {
         stginfo->ffi_type_pointer = *fmt->pffi_type;
     }
@@ -2254,6 +2255,10 @@ set_stginfo_ffi_type_pointer(StgInfo *stginfo, struct fielddesc *fmt)
         memcpy(stginfo->ffi_type_pointer.elements,
                fmt->pffi_type->elements, els_size);
     }
+#else
+    assert(!fmt->pffi_type->elements);
+    stginfo->ffi_type_pointer = *fmt->pffi_type;
+#endif
     return 0;
 }