]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-148967: Fix FFI type pointer handling for C complex support in set_stginfo_ffi_typ...
authorsunmy2019 <59365878+sunmy2019@users.noreply.github.com>
Fri, 1 May 2026 12:12:08 +0000 (20:12 +0800)
committerGitHub <noreply@github.com>
Fri, 1 May 2026 12:12:08 +0000 (14:12 +0200)
Modules/_ctypes/_ctypes.c

index 0bdc30a0cb3836e2ea2df8fc2e7edd08ab8b57ce..5325321efe75cd9b88672fc08a191f2794678108 100644 (file)
@@ -2225,6 +2225,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;
     }
@@ -2244,6 +2245,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;
 }