]> granicus.if.org Git - python/commitdiff
Fix bug #417212: "curses.newwin can return pads" by changing the Python
authorAndrew M. Kuchling <amk@amk.ca>
Sat, 14 Jul 2001 20:38:30 +0000 (20:38 +0000)
committerAndrew M. Kuchling <amk@amk.ca>
Sat, 14 Jul 2001 20:38:30 +0000 (20:38 +0000)
   newwin() wrapper to always return a window, and never a pad.  This makes
   the code match the documentation.

Modules/_cursesmodule.c

index beb8c7ef866e894a7df34377c4100cc04206f0e8..0360994c34d24456d1028d4b2d69f44c61ecd037 100644 (file)
@@ -2051,7 +2051,7 @@ static PyObject *
 PyCurses_NewWindow(PyObject *self, PyObject *args)
 {
   WINDOW *win;
-  int nlines, ncols, begin_y, begin_x;
+  int nlines, ncols, begin_y=0, begin_x=0;
 
   PyCursesInitialised
 
@@ -2059,19 +2059,18 @@ PyCurses_NewWindow(PyObject *self, PyObject *args)
   case 2:
     if (!PyArg_Parse(args,"(ii);nlines,ncols",&nlines,&ncols))
       return NULL;
-    win = newpad(nlines, ncols);
     break;
   case 4:
     if (!PyArg_Parse(args, "(iiii);nlines,ncols,begin_y,begin_x",
                   &nlines,&ncols,&begin_y,&begin_x))
       return NULL;
-    win = newwin(nlines,ncols,begin_y,begin_x);
     break;
   default:
     PyErr_SetString(PyExc_TypeError, "newwin requires 2 or 4 arguments");
     return NULL;
   }
 
+  win = newwin(nlines,ncols,begin_y,begin_x);
   if (win == NULL) {
     PyErr_SetString(PyCursesError, catchall_NULL);
     return NULL;