Mailing List Archive

python/dist/src/Modules _cursesmodule.c,2.69,2.70
Update of /cvsroot/python/python/dist/src/Modules
In directory usw-pr-cvs1:/tmp/cvs-serv13699

Modified Files:
_cursesmodule.c
Log Message:
[Patch #633635 from David M. Cooke]
Make keyname raise ValueError if passed -1, avoiding a segfault
Make getkey() match the docs and raise an exception in nodelay mode
The return type of getch() is int, not chtype


Index: _cursesmodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_cursesmodule.c,v
retrieving revision 2.69
retrieving revision 2.70
diff -C2 -d -r2.69 -r2.70
*** _cursesmodule.c 30 Oct 2002 21:08:34 -0000 2.69
--- _cursesmodule.c 6 Nov 2002 14:15:36 -0000 2.70
***************
*** 733,737 ****
{
int x, y;
! chtype rtn;

switch (PyTuple_Size(args)) {
--- 733,737 ----
{
int x, y;
! int rtn;

switch (PyTuple_Size(args)) {
***************
*** 759,763 ****
{
int x, y;
! chtype rtn;

switch (PyTuple_Size(args)) {
--- 759,763 ----
{
int x, y;
! int rtn;

switch (PyTuple_Size(args)) {
***************
*** 778,782 ****
return NULL;
}
! if (rtn<=255)
return Py_BuildValue("c", rtn);
else
--- 778,786 ----
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
***************
*** 1954,1957 ****
--- 1958,1965 ----
if (!PyArg_ParseTuple(args,"i",&ch)) return NULL;

+ if (ch < 0) {
+ PyErr_SetString(PyExc_ValueError, "invalid key number");
+ return NULL;
+ }
knp = keyname(ch);

***************
*** 2348,2352 ****
{
PyObject *temp;
! chtype ch;

PyCursesInitialised
--- 2356,2360 ----
{
PyObject *temp;
! int ch;

PyCursesInitialised
***************
*** 2355,2361 ****

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");
--- 2363,2369 ----

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");