From: Serhiy Storchaka Date: Sun, 19 Jul 2026 06:23:26 +0000 (+0300) Subject: gh-154048: Fix building the iconv codec on illumos/Solaris (GH-154049) X-Git-Url: http://git.ipfire.org/index.cgi?a=commitdiff_plain;h=33df37dd735777e69c5060c94ee348e89132c63d;p=thirdparty%2FPython%2Fcpython.git gh-154048: Fix building the iconv codec on illumos/Solaris (GH-154049) 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 --- diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index 6562546ae2f9..a4550c0f5f33 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; }