diff options
Diffstat (limited to 'Modules/_cursesmodule.c')
-rw-r--r-- | Modules/_cursesmodule.c | 62 |
1 files changed, 22 insertions, 40 deletions
diff --git a/Modules/_cursesmodule.c b/Modules/_cursesmodule.c index 5069285..e6a2f25 100644 --- a/Modules/_cursesmodule.c +++ b/Modules/_cursesmodule.c @@ -188,8 +188,7 @@ static PyObject * PyCursesCheckERR(int code, const char *fname) { if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { if (fname == NULL) { PyErr_SetString(PyCursesError, catchall_ERR); @@ -414,14 +413,14 @@ PyTypeObject PyCursesWindow_Type; static PyObject * PyCursesWindow_ ## X \ (PyCursesWindowObject *self) \ { \ - if (X (self->win) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ - else { Py_INCREF(Py_True); return Py_True; } } + if (X (self->win) == FALSE) { Py_RETURN_FALSE; } \ + else { Py_RETURN_TRUE; } } #define Window_NoArgNoReturnVoidFunction(X) \ static PyObject * PyCursesWindow_ ## X \ (PyCursesWindowObject *self) \ { \ - X(self->win); Py_INCREF(Py_None); return Py_None; } + X(self->win); Py_RETURN_NONE; } #define Window_NoArg2TupleReturnFunction(X, TYPE, ERGSTR) \ static PyObject * PyCursesWindow_ ## X \ @@ -436,7 +435,7 @@ PyTypeObject PyCursesWindow_Type; { \ TYPE arg1; \ if (!PyArg_ParseTuple(args, PARSESTR, &arg1)) return NULL; \ - X(self->win,arg1); Py_INCREF(Py_None); return Py_None; } + X(self->win,arg1); Py_RETURN_NONE; } #define Window_OneArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject * PyCursesWindow_ ## X \ @@ -900,8 +899,7 @@ PyCursesWindow_Border(PyCursesWindowObject *self, PyObject *args) wborder(self->win, ch[0], ch[1], ch[2], ch[3], ch[4], ch[5], ch[6], ch[7]); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -915,8 +913,7 @@ PyCursesWindow_Box(PyCursesWindowObject *self, PyObject *args) return NULL; } box(self->win,ch1,ch2); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #if defined(HAVE_NCURSES_H) || defined(MVWDELCH_IS_EXPRESSION) @@ -1593,11 +1590,9 @@ PyCursesWindow_Is_LineTouched(PyCursesWindowObject *self, PyObject *args) return NULL; } else if (erg == FALSE) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } else { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } } @@ -2158,8 +2153,7 @@ PyCurses_filter(PyObject *self) /* not checking for PyCursesInitialised here since filter() must be called before initscr() */ filter(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2365,11 +2359,9 @@ static PyObject * PyCurses_has_key(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args,"i",&ch)) return NULL; if (has_key(ch) == FALSE) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } #endif /* STRICT_SYSV_CURSES */ @@ -2566,8 +2558,7 @@ PyCurses_setupterm(PyObject* self, PyObject *args, PyObject* keywds) initialised_setupterm = TRUE; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2603,11 +2594,9 @@ PyCurses_Is_Term_Resized(PyObject *self, PyObject *args) return NULL; result = is_term_resized(lines, columns); if (result == TRUE) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } else { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } } #endif /* HAVE_CURSES_IS_TERM_RESIZED */ @@ -2819,14 +2808,12 @@ PyCurses_QiFlush(PyObject *self, PyObject *args) switch(PyTuple_Size(args)) { case 0: qiflush(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; case 1: if (!PyArg_ParseTuple(args, "i;True(1) or False(0)", &flag)) return NULL; if (flag) qiflush(); else noqiflush(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; default: PyErr_SetString(PyExc_TypeError, "qiflush requires 0 or 1 arguments"); return NULL; @@ -2954,8 +2941,7 @@ PyCurses_setsyx(PyObject *self, PyObject *args) setsyx(y,x); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2979,8 +2965,7 @@ PyCurses_Start_Color(PyObject *self) return NULL; PyDict_SetItemString(ModDict, "COLOR_PAIRS", cp); Py_DECREF(cp); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_SetString(PyCursesError, "start_color() returned ERR"); return NULL; @@ -3025,8 +3010,7 @@ PyCurses_tigetstr(PyObject *self, PyObject *args) capname = tigetstr( capname ); if (capname == 0 || capname == (char*) -1) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyBytes_FromString( capname ); } @@ -3180,8 +3164,7 @@ PyCurses_Use_Env(PyObject *self, PyObject *args) return NULL; } use_env(flag); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #ifndef STRICT_SYSV_CURSES @@ -3195,8 +3178,7 @@ PyCurses_Use_Default_Colors(PyObject *self) code = use_default_colors(); if (code != ERR) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_SetString(PyCursesError, "use_default_colors() returned ERR"); return NULL; |