summaryrefslogtreecommitdiff
path: root/Modules/_cursesmodule.c
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2016-12-27 15:09:36 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2016-12-27 15:09:36 +0200
commit994f04dbf576f4ebafb9de2bc6821e15cb0de0ea (patch)
tree4967ed9c9688f7fe035c646de993c337141051b0 /Modules/_cursesmodule.c
parent58c2c6ebb893917e759cc1401b0d862b3f7c1a94 (diff)
downloadcpython-git-994f04dbf576f4ebafb9de2bc6821e15cb0de0ea.tar.gz
Issue #28998: More APIs now support longs as well as ints.
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r--Modules/_cursesmodule.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c
index e478a57948..9eab741a01 100644
--- a/Modules/_cursesmodule.c
+++ b/Modules/_cursesmodule.c
@@ -194,8 +194,10 @@ PyCursesCheckERR(int code, char *fname)
static int
PyCurses_ConvertToChtype(PyObject *obj, chtype *ch)
{
- if (PyInt_Check(obj)) {
+ if (PyInt_Check(obj) || PyLong_Check(obj)) {
*ch = (chtype) PyInt_AsLong(obj);
+ if (*ch == (chtype) -1 && PyErr_Occurred())
+ return 0;
} else if(PyString_Check(obj)
&& (PyString_Size(obj) == 1)) {
*ch = (chtype) *PyString_AsString(obj);
@@ -2576,8 +2578,11 @@ PyCurses_UnCtrl(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
- if (PyInt_Check(temp))
+ if (PyInt_Check(temp) || PyLong_Check(temp)) {
ch = (chtype) PyInt_AsLong(temp);
+ if (ch == (chtype) -1 && PyErr_Occurred())
+ return NULL;
+ }
else if (PyString_Check(temp))
ch = (chtype) *PyString_AsString(temp);
else {
@@ -2598,8 +2603,11 @@ PyCurses_UngetCh(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args,"O;ch or int",&temp)) return NULL;
- if (PyInt_Check(temp))
+ if (PyInt_Check(temp) || PyLong_Check(temp)) {
ch = (int) PyInt_AsLong(temp);
+ if (ch == -1 && PyErr_Occurred())
+ return NULL;
+ }
else if (PyString_Check(temp))
ch = (int) *PyString_AsString(temp);
else {