diff options
Diffstat (limited to 'Modules/_cursesmodule.c')
| -rw-r--r-- | Modules/_cursesmodule.c | 9 |
1 files changed, 7 insertions, 2 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 1fc7da7..d1cd1551 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -196,8 +196,13 @@ PyCursesCheckERR(int code, char *fname) static int PyCurses_ConvertToChtype(PyObject *obj, chtype *ch) { - if (PyInt_CheckExact(obj)) { - *ch = (chtype) PyLong_AsLong(obj); + if (PyLong_CheckExact(obj)) { + int overflow; + /* XXX should the truncation by the cast also be reported + as an error? */ + *ch = (chtype) PyLong_AsLongAndOverflow(obj, &overflow); + if (overflow) + return 0; } else if(PyString_Check(obj) && (PyString_Size(obj) == 1)) { *ch = (chtype) *PyString_AsString(obj); |
