From 52846d1fe57913a4f4fd097efe70aee951a754f2 Mon Sep 17 00:00:00 2001 From: Victor Stinner Date: Sat, 2 May 2026 15:52:09 +0200 Subject: [PATCH] Fix PyCSimpleType_init() for Zf/Zd/Zg formats --- Modules/_ctypes/_ctypes.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index d13ad0717a5..ebb1de6eacc 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -2415,9 +2415,15 @@ PyCSimpleType_init(PyObject *self, PyObject *args, PyObject *kwds) ml = c_char_p_methods; stginfo->flags |= TYPEFLAG_ISPOINTER; break; - case 'Z': /* c_wchar_p */ - ml = c_wchar_p_methods; - stginfo->flags |= TYPEFLAG_ISPOINTER; + case 'Z': + if (proto_str[1] == '\0') { + /* "Z": c_wchar_p */ + ml = c_wchar_p_methods; + stginfo->flags |= TYPEFLAG_ISPOINTER; + } + else { + ml = NULL; + } break; case 'P': /* c_void_p */ ml = c_void_p_methods;