]> git.ipfire.org Git - thirdparty/Python/cpython.git/commitdiff
gh-154525: Fix curses getcchar() failure on ncurses older than 6.3 (GH-154526) main
authorSerhiy Storchaka <storchaka@gmail.com>
Thu, 23 Jul 2026 14:48:17 +0000 (17:48 +0300)
committerGitHub <noreply@github.com>
Thu, 23 Jul 2026 14:48:17 +0000 (17:48 +0300)
getcchar() rejected a non-NULL opts argument before ncurses 6.3, so read
the color pair through the short slot instead.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
Modules/_cursesmodule.c

index 6df593001b8a1cb9af9c9f51afd7539f05863364..f893c2080fc3f334b75f99e72ca28df2141865b3 100644 (file)
@@ -763,7 +763,9 @@ curses_getcchar(const cchar_t *wcval, wchar_t *wstr, attr_t *attrs, int *pair)
     /* getcchar() is not guaranteed to write the text of an empty cell, so make
        the output an empty string by default. */
     wstr[0] = L'\0';
     /* getcchar() is not guaranteed to write the text of an empty cell, so make
        the output an empty string by default. */
     wstr[0] = L'\0';
-#if _NCURSES_EXTENDED_COLOR_FUNCS
+    /* getcchar()'s opts slot returns the extended color pair, but ncurses
+       returned ERR for a non-NULL opts until 6.3 (patch 20210116). */
+#if _NCURSES_EXTENDED_COLOR_FUNCS && NCURSES_VERSION_PATCH+0 >= 20210116
     int rtn = getcchar(wcval, wstr, attrs, &spair, pair);
 #else
     int rtn = getcchar(wcval, wstr, attrs, &spair, NULL);
     int rtn = getcchar(wcval, wstr, attrs, &spair, pair);
 #else
     int rtn = getcchar(wcval, wstr, attrs, &spair, NULL);