From 5eaea12318c77ebe03f121570615c76c43e32903 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Sun, 19 Jul 2026 08:48:24 +0300 Subject: [PATCH] gh-154048: Fix building the iconv codec on illumos/Solaris iconv()'s input-buffer argument is declared "const char **" on some systems (illumos/Solaris, old GNU libiconv) rather than the POSIX "char **", so passing a "char **" failed to compile. Cast it through void*, which converts to either without a warning. Co-Authored-By: Claude Opus 4.8 --- Objects/unicodeobject.c | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6562546ae2f9ccb..a4550c0f5f3363a 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8279,7 +8279,10 @@ _PyUnicode_DecodeIconv(const char *encoding, char *outptr = (char *)chunk; size_t outleft = sizeof(chunk); - size_t ret = iconv(cd, &inptr, &inleft, &outptr, &outleft); + /* Cast the input buffer through void*: iconv() declares its second + argument as "char **" on most systems but "const char **" on some + (e.g. illumos), and void* converts to either without a warning. */ + size_t ret = iconv(cd, (void *)&inptr, &inleft, &outptr, &outleft); int err = errno; in = inptr; @@ -8452,7 +8455,8 @@ _PyUnicode_EncodeIconv(const char *encoding, PyObject *unicode, size_t outleft = (size_t)(outend - out); /* When the whole string is converted, a final iconv() call with a NULL input flushes any pending shift sequence (e.g. ISO-2022). */ - size_t ret = iconv(cd, flushing ? NULL : &inptr, &inleft, &out, &outleft); + /* See the note above on the void* cast of the iconv() input buffer. */ + size_t ret = iconv(cd, flushing ? NULL : (void *)&inptr, &inleft, &out, &outleft); if (!flushing) { up = inptr; }