FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

gh-153009: Fix compilation of `curses` on platforms that define the `stdscr` macro by picnixz · Pull Request #153010 · python/cpython · GitHub

Repository navigation

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension .c  (1) .h  (1) .rst  (1) All 3 file types selected
Viewed files
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Unified
Split
Hide whitespace
Diff view
Unified
Split
Hide whitespace
2 changes: 1 addition & 1 deletion Include/py_curses.h
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ typedef struct {
SCREEN *screen; /* NULL after the screen has been deleted */
FILE *outfp; /* owned output stream, or NULL */
FILE *infp; /* owned input stream, or NULL */
PyObject *stdscr; /* the screen's standard window, or NULL */
PyObject *stdscr_win; /* the screen's standard window, or NULL */
} PyCursesScreenObject;

#define PyCurses_CAPSULE_NAME "_curses._C_API"
Expand Down
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
Fix compilation of :mod:`curses` on platforms that define the ``stdscr``
macro. Patch by Bénédikt Tran.
18 changes: 9 additions & 9 deletions Modules/_cursesmodule.c
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Original file line number Diff line number Diff line change
Expand Up @@ -5125,7 +5125,7 @@ static PyType_Spec PyCursesWindow_Type_spec = {

static PyObject *
PyCursesScreen_New(cursesmodule_state *state, SCREEN *screen,
FILE *outfp, FILE *infp, PyObject *stdscr)
FILE *outfp, FILE *infp, PyObject *stdscr_win)
{
PyCursesScreenObject *so = PyObject_GC_New(PyCursesScreenObject,
state->screen_type);
Expand All @@ -5135,7 +5135,7 @@ PyCursesScreen_New(cursesmodule_state *state, SCREEN *screen,
so->screen = screen;
so->outfp = outfp;
so->infp = infp;
so->stdscr = Py_XNewRef(stdscr);
so->stdscr_win = Py_XNewRef(stdscr_win);
PyObject_GC_Track((PyObject *)so);
return (PyObject *)so;
}
Expand Down Expand Up @@ -5169,17 +5169,17 @@ static PyObject *
PyCursesScreen_get_stdscr(PyObject *self, void *Py_UNUSED(closure))
{
PyCursesScreenObject *so = _PyCursesScreenObject_CAST(self);
if (so->stdscr == NULL) {
if (so->stdscr_win == NULL) {
Py_RETURN_NONE;
}
return Py_NewRef(so->stdscr);
return Py_NewRef(so->stdscr_win);
}

static int
PyCursesScreen_traverse(PyObject *self, visitproc visit, void *arg)
{
Py_VISIT(Py_TYPE(self));
Py_VISIT(_PyCursesScreenObject_CAST(self)->stdscr);
Py_VISIT(_PyCursesScreenObject_CAST(self)->stdscr_win);
return 0;
}

Expand All @@ -5194,10 +5194,10 @@ PyCursesScreen_clear(PyObject *self)
detach it from its wrapper first: the wrapper must not delwin() a window
that delscreen() frees. Any further use of the wrapper operates on a
NULL window and fails cleanly. */
if (so->stdscr != NULL) {
((PyCursesWindowObject *)so->stdscr)->win = NULL;
if (so->stdscr_win != NULL) {
((PyCursesWindowObject *)so->stdscr_win)->win = NULL;
}
Py_CLEAR(so->stdscr);
Py_CLEAR(so->stdscr_win);
return 0;
}

Expand Down Expand Up @@ -6724,7 +6724,7 @@ _curses_newterm_impl(PyObject *module, const char *type, PyObject *fd,
Py_DECREF(screenobj);
return NULL;
}
((PyCursesScreenObject *)screenobj)->stdscr = Py_NewRef(win);
((PyCursesScreenObject *)screenobj)->stdscr_win = Py_NewRef(win);
Py_DECREF(win);
Py_XSETREF(state->topscreen, Py_NewRef(screenobj));
return screenobj;
Expand Down
Loading

Back | FazBrowse Home | New Git URL