Skip to content

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

Closed

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

  1. gvanem commented on Jul 24, 2026

    @gvanem
    Author

    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).

    Edit: strike the above, apart from the compile-error, it was dead easy after I figured out the missing -DHAVE_x.

  2. added a commit that references this issue on Jul 30, 2026
  3. serhiy-storchaka commented on Jul 30, 2026

    @serhiy-storchaka
    Member

    FYI, last few week I worked on adding support of curses on Windows. It included the identical fix. Will publish the results soon.

  4. added 3 commits that reference this issue on Jul 30, 2026
  5. added a commit that references this issue on Aug 14, 2026
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