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

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions