Index: Modules/_cursesmodule.c =================================================================== RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v retrieving revision 2.69 diff -c -r2.69 _cursesmodule.c *** Modules/_cursesmodule.c 30 Oct 2002 21:08:34 -0000 2.69 --- Modules/_cursesmodule.c 5 Nov 2002 15:37:38 -0000 *************** *** 732,738 **** PyCursesWindow_GetCh(PyCursesWindowObject *self, PyObject *args) { int x, y; ! chtype rtn; switch (PyTuple_Size(args)) { case 0: --- 732,738 ---- PyCursesWindow_GetCh(PyCursesWindowObject *self, PyObject *args) { int x, y; ! int rtn; switch (PyTuple_Size(args)) { case 0: *************** *** 758,764 **** PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) { int x, y; ! chtype rtn; switch (PyTuple_Size(args)) { case 0: --- 758,764 ---- PyCursesWindow_GetKey(PyCursesWindowObject *self, PyObject *args) { int x, y; ! int rtn; switch (PyTuple_Size(args)) { case 0: *************** *** 777,783 **** PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments"); return NULL; } ! if (rtn<=255) return Py_BuildValue("c", rtn); else #if defined(__NetBSD__) --- 777,787 ---- PyErr_SetString(PyExc_TypeError, "getkey requires 0 or 2 arguments"); return NULL; } ! if (rtn == ERR) { ! /* getch() returns ERR in nodelay mode */ ! PyErr_SetString(PyCursesError, "no input"); ! return NULL; ! } else if (rtn<=255) return Py_BuildValue("c", rtn); else #if defined(__NetBSD__) *************** *** 1953,1958 **** --- 1957,1966 ---- if (!PyArg_ParseTuple(args,"i",&ch)) return NULL; + if (ch < 0) { + PyErr_SetString(PyExc_ValueError, "invalid key number"); + return NULL; + } knp = keyname(ch); return PyString_FromString((knp == NULL) ? "" : (char *)knp); *************** *** 2347,2362 **** PyCurses_UngetCh(PyObject *self, PyObject *args) { PyObject *temp; ! chtype ch; PyCursesInitialised if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; if (PyInt_Check(temp)) ! ch = (chtype) PyInt_AsLong(temp); else if (PyString_Check(temp)) ! ch = (chtype) *PyString_AsString(temp); else { PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int"); return NULL; --- 2355,2370 ---- PyCurses_UngetCh(PyObject *self, PyObject *args) { PyObject *temp; ! int ch; PyCursesInitialised if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL; if (PyInt_Check(temp)) ! ch = (int) PyInt_AsLong(temp); else if (PyString_Check(temp)) ! ch = (int) *PyString_AsString(temp); else { PyErr_SetString(PyExc_TypeError, "argument must be a ch or an int"); return NULL; Index: Doc/lib/libcurses.tex =================================================================== RCS file: /cvsroot/python/python/dist/src/Doc/lib/libcurses.tex,v retrieving revision 1.39 diff -c -r1.39 libcurses.tex *** Doc/lib/libcurses.tex 27 Jun 2002 18:30:34 -0000 1.39 --- Doc/lib/libcurses.tex 5 Nov 2002 15:37:38 -0000 *************** *** 701,707 **** \begin{methoddesc}[window]{getch}{\optional{x, y}} Get a character. Note that the integer returned does \emph{not} have to be in \ASCII{} range: function keys, keypad keys and so on return numbers ! higher than 256. In no-delay mode, an exception is raised if there is no input. \end{methoddesc} --- 701,707 ---- \begin{methoddesc}[window]{getch}{\optional{x, y}} Get a character. Note that the integer returned does \emph{not} have to be in \ASCII{} range: function keys, keypad keys and so on return numbers ! higher than 256. In no-delay mode, -1 is returned if there is no input. \end{methoddesc}

AltStyle によって変換されたページ (->オリジナル) /