Skip to content

Building 'Modules/_cursesmodule.c' for Win32 #154587

Description

@gvanem

Compiling Modules/_cursesmodule.c using clang-cl reveals a stupid bug here:

#if defined(MS_WINDOWS)
char *buffer[100];
UINT cp;
cp = GetConsoleOutputCP();
if (cp != 0) {
PyOS_snprintf(buffer, sizeof(buffer), "cp%u", cp);

and consequently a compile-error:

Modules/_cursesmodule.c(1963,27): error: incompatible pointer types passing 'char *[100]' to parameter of type 'char *'
      [-Wincompatible-pointer-types]
 1963 |             PyOS_snprintf(buffer, sizeof(buffer), "cp%u", cp);
      |                           ^~~~~~
./Include\pyerrors.h(324,37): note: passing argument to parameter 'str' here
  324 | PyAPI_FUNC(int) PyOS_snprintf(char *str, size_t size, const char  *format, ...)
      |                                     ^

Surely it should be:

--- a/Modules/_cursesmodule.c 2026-07-23 18:30:17
+++ b/Modules/_cursesmodule.c 2026-07-24 11:06:43
@@ -1956,7 +1956,7 @@
 {
     if (encoding == NULL) {
 #if defined(MS_WINDOWS)
-        char *buffer[100];
+        char buffer[100];
         UINT cp;
         cp = GetConsoleOutputCP();
         if (cp != 0) {

I tried to build with this Curses port: https://github.com/Bill-Gray/PDCursesMod.git
but eventually gave up on all the missing functions.

Apart from a pip install windows-curses, it seems it would be a major task to get
_curses*.pyd to link and work on Windows (from a git-build).
Any pointers?

Linked PRs

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Status
    No status

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions