diff options
author | Martin v. Löwis <martin@v.loewis.de> | 2007-12-04 22:10:37 +0000 |
---|---|---|
committer | Martin v. Löwis <martin@v.loewis.de> | 2007-12-04 22:10:37 +0000 |
commit | d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6 (patch) | |
tree | 17489e6ea4df32ba3b3bbda6e4b31155a460f265 /Modules/_cursesmodule.c | |
parent | 0fbab7ff8d2efd92e222fcc13c0aff0998c3c158 (diff) | |
download | cpython-git-d1a1d1ed802187cd1a9a8a95ac5d758c7acffee6.tar.gz |
Remove PyInt_CheckExact. Add PyLong_AsLongAndOverflow.
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 1fc7da7f1b..d1cd15518c 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); |