Skip to content

Commit b1cf4e1

Browse files
committed
Add 3.8 curses patch
Patch Python 3.8's _cursesmodule.c to be compatible with PDCurses.
1 parent 9c2bca0 commit b1cf4e1

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

py38/_cursesmodule.c

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,6 +109,10 @@ static const char PyCursesVersion[] = "2.2";
109109
#define STRICT_SYSV_CURSES
110110
#endif
111111

112+
#ifdef _WIN32
113+
#include <windows.h>
114+
#endif
115+
112116
#define CURSES_MODULE
113117
#include "py_curses.h"
114118

@@ -2621,7 +2625,7 @@ _curses_color_pair_impl(PyObject *module, short color_number)
26212625
PyCursesInitialised;
26222626
PyCursesInitialisedColor;
26232627

2624-
return PyLong_FromLong((long) (color_number << 8));
2628+
return PyLong_FromLong(COLOR_PAIR(color_number));
26252629
}
26262630

26272631
/*[clinic input]
@@ -3204,7 +3208,9 @@ static PyObject *
32043208
_curses_setupterm_impl(PyObject *module, const char *term, int fd)
32053209
/*[clinic end generated code: output=4584e587350f2848 input=8ac5f78ec6268be3]*/
32063210
{
3211+
#ifndef _WIN32
32073212
int err;
3213+
#endif
32083214

32093215
if (fd == -1) {
32103216
PyObject* sys_stdout;
@@ -3225,6 +3231,7 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
32253231
}
32263232
}
32273233

3234+
#ifndef _WIN32
32283235
if (!initialised_setupterm && setupterm((char *)term, fd, &err) == ERR) {
32293236
const char* s = "setupterm: unknown error";
32303237

@@ -3237,6 +3244,7 @@ _curses_setupterm_impl(PyObject *module, const char *term, int fd)
32373244
PyErr_SetString(PyCursesError,s);
32383245
return NULL;
32393246
}
3247+
#endif
32403248

32413249
initialised_setupterm = TRUE;
32423250

0 commit comments

Comments
 (0)