Index: Include/py_curses.h =================================================================== --- Include/py_curses.h (revision 80097) +++ Include/py_curses.h (working copy) @@ -74,8 +74,9 @@ /* Type declarations */ typedef struct { - PyObject_HEAD - WINDOW *win; + PyObject_HEAD + WINDOW *win; + int delwin_allowed; /* Flag: we don't want to call delwin on stdscr */ } PyCursesWindowObject; #define PyCursesWindow_Check(v) (Py_TYPE(v) == &PyCursesWindow_Type) Index: Lib/threading.py =================================================================== --- Lib/threading.py (revision 80097) +++ Lib/threading.py (working copy) @@ -484,7 +484,8 @@ finally: # Avoid a refcycle if the thread is running a function with # an argument that has a member that points to the thread. - del self.__target, self.__args, self.__kwargs + pass + #del self.__target, self.__args, self.__kwargs def __bootstrap(self): # Wrapper around the real bootstrap code that ignores Index: Modules/_cursesmodule.c =================================================================== --- Modules/_cursesmodule.c (revision 80097) +++ Modules/_cursesmodule.c (working copy) @@ -348,13 +348,14 @@ wo = PyObject_NEW(PyCursesWindowObject, &PyCursesWindow_Type); if (wo == NULL) return NULL; wo->win = win; + wo->delwin_allowed = TRUE; return (PyObject *)wo; } static void PyCursesWindow_Dealloc(PyCursesWindowObject *wo) { - if (wo->win != stdscr) delwin(wo->win); + if (wo->delwin_allowed) delwin(wo->win); PyObject_DEL(wo); } @@ -1907,10 +1908,13 @@ PyCurses_InitScr(PyObject *self) { WINDOW *win; + PyCursesWindowObject *rv; if (initialised == TRUE) { wrefresh(stdscr); - return (PyObject *)PyCursesWindow_New(stdscr); + rv = (PyCursesWindowObject *)PyCursesWindow_New(stdscr); + rv->delwin_allowed = FALSE; + return (PyObject *)rv; } win = initscr(); @@ -2002,7 +2006,9 @@ SetDictInt("LINES", LINES); SetDictInt("COLS", COLS); - return (PyObject *)PyCursesWindow_New(win); + rv = (PyCursesWindowObject *)PyCursesWindow_New(win); + rv->delwin_allowed = FALSE; + return (PyObject *)rv; } static PyObject *