diff options
author | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-23 07:47:21 (GMT) |
---|---|---|
committer | Serhiy Storchaka <storchaka@gmail.com> | 2017-01-23 07:47:21 (GMT) |
commit | 228b12edcce49649d6befa3c03dbcefd5a22ae76 (patch) | |
tree | 1066be6909fb981fcf30e1a8e224d43567bd9b92 | |
parent | 60e6e962bac6a668d0df539ebf526a0a1c69eacd (diff) | |
download | cpython-228b12edcce49649d6befa3c03dbcefd5a22ae76.zip cpython-228b12edcce49649d6befa3c03dbcefd5a22ae76.tar.gz cpython-228b12edcce49649d6befa3c03dbcefd5a22ae76.tar.bz2 |
Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
possible. Patch is writen with Coccinelle.
57 files changed, 225 insertions, 445 deletions
diff --git a/Modules/_blake2/blake2b_impl.c b/Modules/_blake2/blake2b_impl.c index 58b502b..ec9e3c1 100644 --- a/Modules/_blake2/blake2b_impl.c +++ b/Modules/_blake2/blake2b_impl.c @@ -310,8 +310,7 @@ _blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj) #endif /* !WITH_THREAD */ PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff --git a/Modules/_blake2/blake2s_impl.c b/Modules/_blake2/blake2s_impl.c index 11d2e02..42257a2 100644 --- a/Modules/_blake2/blake2s_impl.c +++ b/Modules/_blake2/blake2s_impl.c @@ -310,8 +310,7 @@ _blake2s_blake2s_update(BLAKE2sObject *self, PyObject *obj) #endif /* !WITH_THREAD */ PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff --git a/Modules/_csv.c b/Modules/_csv.c index e5324ae..fb5530a 100644 --- a/Modules/_csv.c +++ b/Modules/_csv.c @@ -152,8 +152,7 @@ static PyObject * get_nullchar_as_None(Py_UCS4 c) { if (c == '\0') { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else return PyUnicode_FromOrdinal(c); @@ -1294,8 +1293,7 @@ csv_writerows(WriterObj *self, PyObject *seqseq) Py_DECREF(row_iter); if (PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static struct PyMethodDef Writer_methods[] = { @@ -1450,8 +1448,7 @@ csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs) return NULL; } Py_DECREF(dialect); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -1459,8 +1456,7 @@ csv_unregister_dialect(PyObject *module, PyObject *name_obj) { if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0) return PyErr_Format(_csvstate_global->error_obj, "unknown dialect"); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/_ctypes/_ctypes.c b/Modules/_ctypes/_ctypes.c index 4908dde..833749a 100644 --- a/Modules/_ctypes/_ctypes.c +++ b/Modules/_ctypes/_ctypes.c @@ -156,8 +156,7 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw) Py_CLEAR(self->key); Py_CLEAR(self->dict); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyTypeObject DictRemover_Type = { @@ -979,8 +978,7 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type) if (-1 == PyDict_SetItemString((PyObject *)dict, "_type_", type)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *_byref(PyObject *); @@ -1496,8 +1494,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value) PyObject *as_parameter; int res; if (value == Py_None) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (PyUnicode_Check(value)) { PyCArgObject *parg; @@ -1561,8 +1558,7 @@ c_char_p_from_param(PyObject *type, PyObject *value) PyObject *as_parameter; int res; if (value == Py_None) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (PyBytes_Check(value)) { PyCArgObject *parg; @@ -1629,8 +1625,7 @@ c_void_p_from_param(PyObject *type, PyObject *value) /* None */ if (value == Py_None) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Should probably allow buffer interface as well */ /* int, long */ @@ -2602,8 +2597,7 @@ PyCData_setstate(PyObject *myself, PyObject *args) Py_DECREF(mydict); if (res == -1) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* @@ -2825,8 +2819,7 @@ _PyCData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value, return result; } else if (value == Py_None && PyCPointerTypeObject_Check(type)) { *(void **)ptr = NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_Format(PyExc_TypeError, "expected %s instance, got %s", @@ -2980,8 +2973,7 @@ PyCFuncPtr_get_errcheck(PyCFuncPtrObject *self) Py_INCREF(self->errcheck); return self->errcheck; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static int @@ -3019,8 +3011,7 @@ PyCFuncPtr_get_restype(PyCFuncPtrObject *self) Py_INCREF(dict->restype); return dict->restype; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -3057,8 +3048,7 @@ PyCFuncPtr_get_argtypes(PyCFuncPtrObject *self) Py_INCREF(dict->argtypes); return dict->argtypes; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } diff --git a/Modules/_ctypes/_ctypes_test.c b/Modules/_ctypes/_ctypes_test.c index 629ddf6..92b5adb 100644 --- a/Modules/_ctypes/_ctypes_test.c +++ b/Modules/_ctypes/_ctypes_test.c @@ -363,8 +363,7 @@ PyObject *py_func_si(PyObject *self, PyObject *args) int i; if (!PyArg_ParseTuple(args, "si", &name, &i)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } EXPORT(void) _py_func_si(char *s, int i) @@ -373,8 +372,7 @@ EXPORT(void) _py_func_si(char *s, int i) PyObject *py_func(PyObject *self, PyObject *args) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } EXPORT(void) _py_func(void) diff --git a/Modules/_ctypes/callproc.c b/Modules/_ctypes/callproc.c index f408fd3..9b368ca 100644 --- a/Modules/_ctypes/callproc.c +++ b/Modules/_ctypes/callproc.c @@ -892,8 +892,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker) return PyLong_FromLong(*(int *)result); if (restype == Py_None) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } dict = PyType_stgdict(restype); @@ -1263,8 +1262,7 @@ static PyObject *free_library(PyObject *self, PyObject *args) return NULL; if (!FreeLibrary((HMODULE)hMod)) return PyErr_SetFromWindowsErr(GetLastError()); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static const char copy_com_pointer_doc[] = @@ -1349,8 +1347,7 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args) ctypes_dlerror()); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *py_dl_sym(PyObject *self, PyObject *args) @@ -1624,8 +1621,7 @@ resize(PyObject *self, PyObject *args) obj->b_size = size; } done: - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c index a43585f..ec30b8c 100644 --- a/Modules/_ctypes/cfield.c +++ b/Modules/_ctypes/cfield.c @@ -1337,8 +1337,7 @@ z_get(void *ptr, Py_ssize_t size) return PyBytes_FromStringAndSize(*(char **)ptr, strlen(*(char **)ptr)); } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -1360,8 +1359,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size) #else *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value); #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (!PyUnicode_Check(value)) { PyErr_Format(PyExc_TypeError, @@ -1392,8 +1390,7 @@ Z_get(void *ptr, Py_ssize_t size) if (p) { return PyUnicode_FromWideChar(p, wcslen(p)); } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } #endif @@ -1452,8 +1449,7 @@ BSTR_get(void *ptr, Py_ssize_t size) /* Hm, it seems NULL pointer and zero length string are the same in BSTR, see Don Box, p 81 */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } #endif @@ -1493,8 +1489,7 @@ static PyObject * P_get(void *ptr, Py_ssize_t size) { if (*(void **)ptr == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyLong_FromVoidPtr(*(void **)ptr); } diff --git a/Modules/_curses_panel.c b/Modules/_curses_panel.c index 18ef335..a98d2bf 100644 --- a/Modules/_curses_panel.c +++ b/Modules/_curses_panel.c @@ -59,8 +59,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(_curses_panelstate_global->PyCursesError, catchall_ERR); @@ -177,8 +176,8 @@ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ #define Panel_NoArgTrueFalseFunction(X) \ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ { \ - if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ - else { Py_INCREF(Py_True); return Py_True; } } + if (X (self->pan) == FALSE) { Py_RETURN_FALSE; } \ + else { Py_RETURN_TRUE; } } #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ @@ -245,8 +244,7 @@ PyCursesPanel_above(PyCursesPanelObject *self) if (pan == NULL) { /* valid output, it means the calling panel is on top of the stack */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -270,8 +268,7 @@ PyCursesPanel_below(PyCursesPanelObject *self) if (pan == NULL) { /* valid output, it means the calling panel is on the bottom of the stack */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -319,8 +316,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args) } Py_INCREF(temp); Py_SETREF(po->wo, temp); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -406,8 +402,7 @@ PyCurses_bottom_panel(PyObject *self) if (pan == NULL) { /* valid output, it means there's no panel at all */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -452,8 +447,7 @@ PyCurses_top_panel(PyObject *self) if (pan == NULL) { /* valid output, it means there's no panel at all */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } po = find_po(pan); if (po == NULL) { @@ -469,8 +463,7 @@ static PyObject *PyCurses_update_panels(PyObject *self) { PyCursesInitialised; update_panels(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } 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; diff --git a/Modules/_dbmmodule.c b/Modules/_dbmmodule.c index 52bdd0b..4b3fac4 100644 --- a/Modules/_dbmmodule.c +++ b/Modules/_dbmmodule.c @@ -187,8 +187,7 @@ _dbm_dbm_close_impl(dbmobject *self) if (self->di_dbm) dbm_close(self->di_dbm); self->di_dbm = NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff --git a/Modules/_gdbmmodule.c b/Modules/_gdbmmodule.c index b727ba6..54a6566 100644 --- a/Modules/_gdbmmodule.c +++ b/Modules/_gdbmmodule.c @@ -255,8 +255,7 @@ _gdbm_gdbm_close_impl(dbmobject *self) if (self->di_dbm) gdbm_close(self->di_dbm); self->di_dbm = NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* XXX Should return a set or a set view */ @@ -375,8 +374,7 @@ _gdbm_gdbm_firstkey_impl(dbmobject *self) return v; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -415,8 +413,7 @@ _gdbm_gdbm_nextkey_impl(dbmobject *self, const char *key, return v; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -445,8 +442,7 @@ _gdbm_gdbm_reorganize_impl(dbmobject *self) PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno)); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -464,8 +460,7 @@ _gdbm_gdbm_sync_impl(dbmobject *self) { check_dbmobject_open(self); gdbm_sync(self->di_dbm); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/_io/bufferedio.c b/Modules/_io/bufferedio.c index cb4173e..6c88bbb 100644 --- a/Modules/_io/bufferedio.c +++ b/Modules/_io/bufferedio.c @@ -1689,8 +1689,7 @@ _bufferedreader_read_generic(buffered *self, Py_ssize_t n) return res; } Py_DECREF(res); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } remaining -= r; written += r; @@ -1714,8 +1713,7 @@ _bufferedreader_read_generic(buffered *self, Py_ssize_t n) return res; } Py_DECREF(res); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (remaining > r) { memcpy(out + written, self->buffer + self->pos, r); diff --git a/Modules/_lsprof.c b/Modules/_lsprof.c index 0e7623d..6027470 100644 --- a/Modules/_lsprof.c +++ b/Modules/_lsprof.c @@ -692,8 +692,7 @@ profiler_enable(ProfilerObject *self, PyObject *args, PyObject *kwds) return NULL; PyEval_SetProfile(profiler_callback, (PyObject*)self); self->flags |= POF_ENABLED; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static void @@ -726,8 +725,7 @@ profiler_disable(ProfilerObject *self, PyObject* noarg) flush_unmatched(self); if (pending_exception(self)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(clear_doc, "\ @@ -740,8 +738,7 @@ static PyObject* profiler_clear(ProfilerObject *pObj, PyObject* noarg) { clearEntries(pObj); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static void diff --git a/Modules/_randommodule.c b/Modules/_randommodule.c index 0d3282d..976054c 100644 --- a/Modules/_randommodule.c +++ b/Modules/_randommodule.c @@ -376,8 +376,7 @@ random_setstate(RandomObject *self, PyObject *state) } self->index = (int)index; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/_scproxy.c b/Modules/_scproxy.c index 1ce4b77..0e3b028 100644 --- a/Modules/_scproxy.c +++ b/Modules/_scproxy.c @@ -64,8 +64,7 @@ get_proxy_settings(PyObject* mod __attribute__((__unused__))) proxyDict = SCDynamicStoreCopyProxies(NULL); if (!proxyDict) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyDict_New(); diff --git a/Modules/_sha3/sha3module.c b/Modules/_sha3/sha3module.c index 11aaa1f..33b77b1 100644 --- a/Modules/_sha3/sha3module.c +++ b/Modules/_sha3/sha3module.c @@ -403,8 +403,7 @@ _sha3_sha3_224_update(SHA3object *self, PyObject *obj) } PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/Modules/_sqlite/connection.c b/Modules/_sqlite/connection.c index 7bbc15c..37b45f3 100644 --- a/Modules/_sqlite/connection.c +++ b/Modules/_sqlite/connection.c @@ -400,8 +400,7 @@ error: if (PyErr_Occurred()) { return NULL; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -443,8 +442,7 @@ error: if (PyErr_Occurred()) { return NULL; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -487,8 +485,7 @@ error: if (PyErr_Occurred()) { return NULL; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } diff --git a/Modules/_sre.c b/Modules/_sre.c index 1cef7d0..061af39 100644 --- a/Modules/_sre.c +++ b/Modules/_sre.c @@ -481,8 +481,7 @@ state_getslice(SRE_STATE* state, Py_ssize_t index, PyObject* string, int empty) /* want empty string */ i = j = 0; else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } else { i = STATE_OFFSET(state, state->mark[index]); @@ -2368,8 +2367,7 @@ match_lastindex_get(MatchObject *self) { if (self->lastindex >= 0) return PyLong_FromSsize_t(self->lastindex); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2383,8 +2381,7 @@ match_lastgroup_get(MatchObject *self) return result; PyErr_Clear(); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2466,8 +2463,7 @@ pattern_new_match(PatternObject* pattern, SRE_STATE* state, Py_ssize_t status) } else if (status == 0) { /* no match */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/Modules/_ssl.c b/Modules/_ssl.c index 6003476..1e9a707 100644 --- a/Modules/_ssl.c +++ b/Modules/_ssl.c @@ -755,8 +755,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self) PySSL_END_ALLOW_THREADS self->handshake_done = 1; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; error: Py_XDECREF(sock); @@ -4500,8 +4499,7 @@ _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy) buf += written; len -= written; } while (len); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c index ef5f9d4..6d6b72a 100644 --- a/Modules/_testcapimodule.c +++ b/Modules/_testcapimodule.c @@ -64,8 +64,7 @@ test_config(PyObject *self) #undef CHECK_SIZEOF - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -169,8 +168,7 @@ test_list_api(PyObject *self) Py_DECREF(list); #undef NLIST - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static int @@ -234,8 +232,7 @@ test_dict_iteration(PyObject* self) } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -614,8 +611,7 @@ test_long_and_overflow(PyObject *self) return raiseTestError("test_long_and_overflow", "overflow was not cleared"); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Test the PyLong_AsLongLongAndOverflow API. General conversion to @@ -779,8 +775,7 @@ test_long_long_and_overflow(PyObject *self) return raiseTestError("test_long_long_and_overflow", "overflow was not cleared"); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Test the PyLong_As{Size,Ssize}_t API. At present this just tests that @@ -887,8 +882,7 @@ test_L_code(PyObject *self) "L code returned wrong value for int 42"); Py_DECREF(tuple); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -1224,8 +1218,7 @@ test_k_code(PyObject *self) "k code returned wrong value for long -0xFFF..000042"); Py_DECREF(tuple); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -1672,8 +1665,7 @@ test_u_code(PyObject *self) "u# code returned wrong values for u'test'"); Py_DECREF(tuple); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Test Z and Z# codes for PyArg_ParseTuple */ @@ -2118,8 +2110,7 @@ test_long_numbits(PyObject *self) return raiseTestError("test_long_numbits", "wrong result for _PyLong_Sign"); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Example passing NULLs to PyObject_Str(NULL). */ @@ -2336,11 +2327,9 @@ PyObject *pending_threadfunc(PyObject *self, PyObject *arg) if (r<0) { Py_DECREF(callable); /* unsuccessful add, destroy the extra reference */ - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } #endif @@ -2726,8 +2715,7 @@ profile_int(PyObject *self, PyObject* args) Py_DECREF(op1); print_delta(7, &start, &stop); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif diff --git a/Modules/_testmultiphase.c b/Modules/_testmultiphase.c index 4daa34e..9b04ebf 100644 --- a/Modules/_testmultiphase.c +++ b/Modules/_testmultiphase.c @@ -36,8 +36,7 @@ Example_demo(ExampleObject *self, PyObject *args) Py_INCREF(o); return o; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/Modules/_threadmodule.c b/Modules/_threadmodule.c index 0219559..8be9306 100644 --- a/Modules/_threadmodule.c +++ b/Modules/_threadmodule.c @@ -180,8 +180,7 @@ lock_PyThread_release_lock(lockobject *self) PyThread_release_lock(self->lock_lock); self->locked = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(release_doc, @@ -1111,8 +1110,7 @@ static PyObject * thread_PyThread_interrupt_main(PyObject * self) { PyErr_SetInterrupt(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(interrupt_doc, diff --git a/Modules/arraymodule.c b/Modules/arraymodule.c index f1469df..464820d 100644 --- a/Modules/arraymodule.c +++ b/Modules/arraymodule.c @@ -1007,8 +1007,7 @@ ins(arrayobject *self, Py_ssize_t where, PyObject *v) { if (ins1(self, where, v) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1122,8 +1121,7 @@ array_array_remove(arrayobject *self, PyObject *v) if (cmp > 0) { if (array_del_slice(self, i, i+1) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else if (cmp < 0) return NULL; @@ -1185,8 +1183,7 @@ array_array_extend(arrayobject *self, PyObject *bb) { if (array_do_extend(self, bb) == -1) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1315,8 +1312,7 @@ array_array_byteswap_impl(arrayobject *self) "don't know how to byteswap this array type"); return NULL; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1349,8 +1345,7 @@ array_array_reverse_impl(arrayobject *self) } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1453,8 +1448,7 @@ array_array_tofile(arrayobject *self, PyObject *f) } done: - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1491,8 +1485,7 @@ array_array_fromlist(arrayobject *self, PyObject *list) } } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1557,8 +1550,7 @@ frombytes(arrayobject *self, Py_buffer *buffer) buffer->buf, n * itemsize); } PyBuffer_Release(buffer); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff --git a/Modules/faulthandler.c b/Modules/faulthandler.c index ac6ab7e..4fc8ebd 100644 --- a/Modules/faulthandler.c +++ b/Modules/faulthandler.c @@ -521,12 +521,10 @@ static PyObject* faulthandler_disable_py(PyObject *self) { if (!fatal_error.enabled) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } faulthandler_disable(); - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } static PyObject* diff --git a/Modules/fpectlmodule.c b/Modules/fpectlmodule.c index 052b834..8e05803 100644 --- a/Modules/fpectlmodule.c +++ b/Modules/fpectlmodule.c @@ -102,8 +102,7 @@ static PyObject *turnon_sigfpe(PyObject *self,PyObject *args) /* Do any architecture-specific one-time only initialization here. */ fpe_reset(sigfpe_handler); - Py_INCREF (Py_None); - return Py_None; + Py_RETURN_NONE; } static void fpe_reset(Sigfunc *handler) @@ -233,8 +232,7 @@ static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args) #else fputs("Operation not implemented\n", stderr); #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static void sigfpe_handler(int signo) diff --git a/Modules/fpetestmodule.c b/Modules/fpetestmodule.c index 5b6c220..1c232c9 100644 --- a/Modules/fpetestmodule.c +++ b/Modules/fpetestmodule.c @@ -95,8 +95,7 @@ static PyObject *test(PyObject *self,PyObject *args) r = nest2(2, 2.0); printerr(r); - Py_INCREF (Py_None); - return Py_None; + Py_RETURN_NONE; } static void printerr(double r) diff --git a/Modules/gcmodule.c b/Modules/gcmodule.c index 754348e..0a342cb 100644 --- a/Modules/gcmodule.c +++ b/Modules/gcmodule.c @@ -1164,8 +1164,7 @@ static PyObject * gc_enable(PyObject *self, PyObject *noargs) { enabled = 1; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(gc_disable__doc__, @@ -1177,8 +1176,7 @@ static PyObject * gc_disable(PyObject *self, PyObject *noargs) { enabled = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(gc_isenabled__doc__, @@ -1246,8 +1244,7 @@ gc_set_debug(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:set_debug", &debug)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(gc_get_debug__doc__, @@ -1281,8 +1278,7 @@ gc_set_thresh(PyObject *self, PyObject *args) generations[i].threshold = generations[2].threshold; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(gc_get_thresh__doc__, diff --git a/Modules/md5module.c b/Modules/md5module.c index 04bc06e..6b11f0b 100644 --- a/Modules/md5module.c +++ b/Modules/md5module.c @@ -416,8 +416,7 @@ MD5Type_update(MD5object *self, PyObject *obj) md5_process(&self->hash_state, buf.buf, buf.len); PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef MD5_methods[] = { diff --git a/Modules/mmapmodule.c b/Modules/mmapmodule.c index 5f1615f..7a94464 100644 --- a/Modules/mmapmodule.c +++ b/Modules/mmapmodule.c @@ -181,8 +181,7 @@ mmap_close_method(mmap_object *self, PyObject *unused) } #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #ifdef MS_WINDOWS @@ -415,8 +414,7 @@ mmap_write_byte_method(mmap_object *self, if (self->pos < self->size) { self->data[self->pos++] = value; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { PyErr_SetString(PyExc_ValueError, "write byte out of range"); @@ -524,8 +522,7 @@ mmap_resize_method(mmap_object *self, new_size); if (self->data != NULL) { self->size = new_size; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { dwErrCode = GetLastError(); CloseHandle(self->map_handle); @@ -567,8 +564,7 @@ mmap_resize_method(mmap_object *self, } self->data = newmap; self->size = new_size; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; #endif /* HAVE_MREMAP */ #endif /* UNIX */ } @@ -644,8 +640,7 @@ mmap_seek_method(mmap_object *self, PyObject *args) if (where > self->size || where < 0) goto onoutofrange; self->pos = where; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } onoutofrange: @@ -670,8 +665,7 @@ mmap_move_method(mmap_object *self, PyObject *args) memmove(&self->data[dest], &self->data[src], cnt); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; bounds: PyErr_SetString(PyExc_ValueError, diff --git a/Modules/ossaudiodev.c b/Modules/ossaudiodev.c index 5f0505c..1cdbbae 100644 --- a/Modules/ossaudiodev.c +++ b/Modules/ossaudiodev.c @@ -307,8 +307,7 @@ _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd) if (rv == -1) return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -326,8 +325,7 @@ oss_nonblock(oss_audio_t *self, PyObject *unused) mode once we're in non-blocking mode! */ if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) return PyErr_SetFromErrno(PyExc_IOError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -514,8 +512,7 @@ oss_writeall(oss_audio_t *self, PyObject *args) cp += rv; } PyBuffer_Release(&data); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -527,8 +524,7 @@ oss_close(oss_audio_t *self, PyObject *unused) Py_END_ALLOW_THREADS self->fd = -1; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -747,8 +743,7 @@ oss_mixer_close(oss_mixer_t *self, PyObject *unused) close(self->fd); self->fd = -1; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/parsermodule.c b/Modules/parsermodule.c index b2566951..e5c4db3 100644 --- a/Modules/parsermodule.c +++ b/Modules/parsermodule.c @@ -91,8 +91,7 @@ node2tuple(node *n, /* node to convert */ PyObject *result = NULL, *w; if (n == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (ISNONTERMINAL(TYPE(n))) { diff --git a/Modules/posixmodule.c b/Modules/posixmodule.c index d2ff07f..48c3c7a 100644 --- a/Modules/posixmodule.c +++ b/Modules/posixmodule.c @@ -1871,8 +1871,7 @@ stat_float_times(PyObject* self, PyObject *args) /* Return old value */ return PyBool_FromLong(_stat_float_times); _stat_float_times = newval; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject *billion = NULL; @@ -6194,8 +6193,7 @@ posix_initgroups(PyObject *self, PyObject *args) if (res == -1) return PyErr_SetFromErrno(PyExc_OSError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif /* HAVE_INITGROUPS */ @@ -6258,8 +6256,7 @@ os_setpgrp_impl(PyObject *module) if (setpgrp() < 0) #endif /* SETPGRP_HAVE_ARG */ return posix_error(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif /* HAVE_SETPGRP */ @@ -6585,8 +6582,7 @@ os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid) if (setreuid(ruid, euid) < 0) { return posix_error(); } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } #endif /* HAVE_SETREUID */ @@ -6681,8 +6677,7 @@ os_setgroups(PyObject *module, PyObject *groups) if (setgroups(len, grouplist) < 0) return posix_error(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif /* HAVE_SETGROUPS */ diff --git a/Modules/pyexpat.c b/Modules/pyexpat.c index ece4d16..03bac57 100644 --- a/Modules/pyexpat.c +++ b/Modules/pyexpat.c @@ -161,8 +161,7 @@ conv_string_to_unicode(const XML_Char *str) and hence in UTF-8. */ /* UTF-8 from Expat, Unicode desired */ if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_DecodeUTF8(str, strlen(str), "strict"); } @@ -174,8 +173,7 @@ conv_string_len_to_unicode(const XML_Char *str, int len) and hence in UTF-8. */ /* UTF-8 from Expat, Unicode desired */ if (str == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_DecodeUTF8((const char *)str, len, "strict"); } @@ -1030,8 +1028,7 @@ pyexpat_xmlparser_UseForeignDTD_impl(xmlparseobject *self, int flag) if (rc != XML_ERROR_NONE) { return set_error(self, rc); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif @@ -1322,8 +1319,7 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj) return get_pybool((long) self->specified_attributes); if (_PyUnicode_EqualToASCIIString(nameobj, "intern")) { if (self->intern == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { Py_INCREF(self->intern); diff --git a/Modules/selectmodule.c b/Modules/selectmodule.c index 0206651..8bdf335 100644 --- a/Modules/selectmodule.c +++ b/Modules/selectmodule.c @@ -431,8 +431,7 @@ poll_register(pollObject *self, PyObject *args) self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(poll_modify_doc, @@ -479,8 +478,7 @@ poll_modify(pollObject *self, PyObject *args) self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -513,8 +511,7 @@ poll_unregister(pollObject *self, PyObject *o) Py_DECREF(key); self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(poll_poll_doc, diff --git a/Modules/sha1module.c b/Modules/sha1module.c index d5065ce..d39190b 100644 --- a/Modules/sha1module.c +++ b/Modules/sha1module.c @@ -393,8 +393,7 @@ SHA1Type_update(SHA1object *self, PyObject *obj) sha1_process(&self->hash_state, buf.buf, buf.len); PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef SHA1_methods[] = { diff --git a/Modules/sha256module.c b/Modules/sha256module.c index 8f067f1..e4cb328 100644 --- a/Modules/sha256module.c +++ b/Modules/sha256module.c @@ -483,8 +483,7 @@ SHA256Type_update(SHAobject *self, PyObject *obj) sha_update(self, buf.buf, buf.len); PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef SHA_methods[] = { diff --git a/Modules/sha512module.c b/Modules/sha512module.c index 17775ae5..8b2d073 100644 --- a/Modules/sha512module.c +++ b/Modules/sha512module.c @@ -548,8 +548,7 @@ SHA512Type_update(SHAobject *self, PyObject *obj) sha512_update(self, buf.buf, buf.len); PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] dump buffer diff --git a/Modules/socketmodule.c b/Modules/socketmodule.c index 274769d..8d0f9e6 100644 --- a/Modules/socketmodule.c +++ b/Modules/socketmodule.c @@ -1218,8 +1218,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto) { if (addrlen == 0) { /* No address -- may be recvfrom() from known socket */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (addr->sa_family) { @@ -2540,8 +2539,7 @@ static PyObject * sock_gettimeout(PySocketSockObject *s) { if (s->sock_timeout < 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { double seconds = _PyTime_AsSecondsDouble(s->sock_timeout); @@ -2701,8 +2699,7 @@ sock_bind(PySocketSockObject *s, PyObject *addro) Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(bind_doc, @@ -2738,8 +2735,7 @@ sock_close(PySocketSockObject *s) return s->errorhandler(); } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(close_doc, @@ -2996,8 +2992,7 @@ sock_listen(PySocketSockObject *s, PyObject *args) Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(listen_doc, @@ -4363,8 +4358,7 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg) Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(shutdown_doc, @@ -6196,8 +6190,7 @@ static PyObject * socket_getdefaulttimeout(PyObject *self) { if (defaulttimeout < 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } else { double seconds = _PyTime_AsSecondsDouble(defaulttimeout); @@ -6222,8 +6215,7 @@ socket_setdefaulttimeout(PyObject *self, PyObject *arg) defaulttimeout = timeout; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setdefaulttimeout_doc, diff --git a/Modules/syslogmodule.c b/Modules/syslogmodule.c index 412e436..a5807dc 100644 --- a/Modules/syslogmodule.c +++ b/Modules/syslogmodule.c @@ -147,8 +147,7 @@ syslog_openlog(PyObject * self, PyObject * args, PyObject *kwds) openlog(ident, logopt, facility); S_log_open = 1; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -200,8 +199,7 @@ syslog_closelog(PyObject *self, PyObject *unused) Py_CLEAR(S_ident_o); S_log_open = 0; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Modules/termios.c b/Modules/termios.c index b78d33e..6ed4395 100644 --- a/Modules/termios.c +++ b/Modules/termios.c @@ -194,8 +194,7 @@ termios_tcsetattr(PyObject *self, PyObject *args) if (tcsetattr(fd, when, &mode) == -1) return PyErr_SetFromErrno(TermiosError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(termios_tcsendbreak__doc__, @@ -216,8 +215,7 @@ termios_tcsendbreak(PyObject *self, PyObject *args) if (tcsendbreak(fd, duration) == -1) return PyErr_SetFromErrno(TermiosError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(termios_tcdrain__doc__, @@ -236,8 +234,7 @@ termios_tcdrain(PyObject *self, PyObject *args) if (tcdrain(fd) == -1) return PyErr_SetFromErrno(TermiosError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(termios_tcflush__doc__, @@ -259,8 +256,7 @@ termios_tcflush(PyObject *self, PyObject *args) if (tcflush(fd, queue) == -1) return PyErr_SetFromErrno(TermiosError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(termios_tcflow__doc__, @@ -282,8 +278,7 @@ termios_tcflow(PyObject *self, PyObject *args) if (tcflow(fd, action) == -1) return PyErr_SetFromErrno(TermiosError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef termios_methods[] = diff --git a/Modules/timemodule.c b/Modules/timemodule.c index a3319a2..25eb92d 100644 --- a/Modules/timemodule.c +++ b/Modules/timemodule.c @@ -234,8 +234,7 @@ time_sleep(PyObject *self, PyObject *obj) } if (pysleep(secs) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(sleep_doc, @@ -879,8 +878,7 @@ time_tzset(PyObject *self, PyObject *unused) if (PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(tzset_doc, diff --git a/Modules/zipimport.c b/Modules/zipimport.c index 950e4f4..18777b2 100644 --- a/Modules/zipimport.c +++ b/Modules/zipimport.c @@ -677,8 +677,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args) } /* we have the module, but no source */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(doc_find_module, @@ -1284,8 +1283,7 @@ unmarshal_code(PyObject *pathname, PyObject *data, time_t mtime) PySys_FormatStderr("# %R has bad magic\n", pathname); } - Py_INCREF(Py_None); - return Py_None; /* signal caller to try alternative */ + Py_RETURN_NONE; /* signal caller to try alternative */ } if (mtime != 0 && !eq_mtime(get_uint32(buf + 4), mtime)) { @@ -1293,8 +1291,7 @@ unmarshal_code(PyObject *pathname, PyObject *data, time_t mtime) PySys_FormatStderr("# %R has bad mtime\n", pathname); } - Py_INCREF(Py_None); - return Py_None; /* signal caller to try alternative */ + Py_RETURN_NONE; /* signal caller to try alternative */ } /* XXX the pyc's size field is ignored; timestamp collisions are probably diff --git a/Objects/descrobject.c b/Objects/descrobject.c index a254a2a..3fb34a3 100644 --- a/Objects/descrobject.c +++ b/Objects/descrobject.c @@ -419,8 +419,7 @@ static PyObject * member_get_doc(PyMemberDescrObject *descr, void *closure) { if (descr->d_member->doc == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_FromString(descr->d_member->doc); } @@ -435,8 +434,7 @@ static PyObject * getset_get_doc(PyGetSetDescrObject *descr, void *closure) { if (descr->d_getset->doc == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_FromString(descr->d_getset->doc); } diff --git a/Objects/exceptions.c b/Objects/exceptions.c index 57a786c..35a8b66 100644 --- a/Objects/exceptions.c +++ b/Objects/exceptions.c @@ -184,8 +184,7 @@ static PyObject * BaseException_get_args(PyBaseExceptionObject *self) { if (self->args == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } Py_INCREF(self->args); return self->args; @@ -210,8 +209,7 @@ static PyObject * BaseException_get_tb(PyBaseExceptionObject *self) { if (self->traceback == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } Py_INCREF(self->traceback); return self->traceback; diff --git a/Objects/fileobject.c b/Objects/fileobject.c index fcdb5fd..3c3d46d 100644 --- a/Objects/fileobject.c +++ b/Objects/fileobject.c @@ -456,8 +456,7 @@ static PyMethodDef stdprinter_methods[] = { static PyObject * get_closed(PyStdPrinter_Object *self, void *closure) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } static PyObject * diff --git a/Objects/funcobject.c b/Objects/funcobject.c index a3af4b3..8ac88b1 100644 --- a/Objects/funcobject.c +++ b/Objects/funcobject.c @@ -322,8 +322,7 @@ static PyObject * func_get_defaults(PyFunctionObject *op) { if (op->func_defaults == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } Py_INCREF(op->func_defaults); return op->func_defaults; @@ -350,8 +349,7 @@ static PyObject * func_get_kwdefaults(PyFunctionObject *op) { if (op->func_kwdefaults == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } Py_INCREF(op->func_kwdefaults); return op->func_kwdefaults; diff --git a/Objects/genobject.c b/Objects/genobject.c index 59f53ce..24a1da6 100644 --- a/Objects/genobject.c +++ b/Objects/genobject.c @@ -402,8 +402,7 @@ gen_close(PyGenObject *gen, PyObject *args) if (PyErr_ExceptionMatches(PyExc_StopIteration) || PyErr_ExceptionMatches(PyExc_GeneratorExit)) { PyErr_Clear(); /* ignore these errors */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return NULL; } diff --git a/Objects/listobject.c b/Objects/listobject.c index b21f637..8994174 100644 --- a/Objects/listobject.c +++ b/Objects/listobject.c @@ -2284,12 +2284,10 @@ list_richcompare(PyObject *v, PyObject *w, int op) /* We have an item that differs -- shortcuts for EQ/NE */ if (op == Py_EQ) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } if (op == Py_NE) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } /* Compare the final item again using the proper operator */ diff --git a/Objects/tupleobject.c b/Objects/tupleobject.c index c0ff499..5bcadeb 100644 --- a/Objects/tupleobject.c +++ b/Objects/tupleobject.c @@ -631,12 +631,10 @@ tuplerichcompare(PyObject *v, PyObject *w, int op) /* We have an item that differs -- shortcuts for EQ/NE */ if (op == Py_EQ) { - Py_INCREF(Py_False); - return Py_False; + Py_RETURN_FALSE; } if (op == Py_NE) { - Py_INCREF(Py_True); - return Py_True; + Py_RETURN_TRUE; } /* Compare the final item again using the proper operator */ diff --git a/Objects/typeobject.c b/Objects/typeobject.c index 0fdff31..bf6d3f1 100644 --- a/Objects/typeobject.c +++ b/Objects/typeobject.c @@ -140,8 +140,7 @@ _PyType_GetDocFromInternalDoc(const char *name, const char *internal_doc) const char *doc = _PyType_DocWithoutSignature(name, internal_doc); if (!doc || *doc == '\0') { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyUnicode_FromString(doc); @@ -158,8 +157,7 @@ _PyType_GetTextSignatureFromInternalDoc(const char *name, const char *internal_d else end = NULL; if (!end) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* back "end" up until it points just past the final ')' */ @@ -761,8 +759,7 @@ static PyObject * type_dict(PyTypeObject *type, void *context) { if (type->tp_dict == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } return PyDictProxy_New(type->tp_dict); } @@ -5330,8 +5327,7 @@ wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped) res = (*func)(self, i, value); if (res == -1 && PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5351,8 +5347,7 @@ wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped) res = (*func)(self, i, NULL); if (res == -1 && PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* XXX objobjproc is a misnomer; should be objargpred */ @@ -5385,8 +5380,7 @@ wrap_objobjargproc(PyObject *self, PyObject *args, void *wrapped) res = (*func)(self, key, value); if (res == -1 && PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5402,8 +5396,7 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped) res = (*func)(self, key, NULL); if (res == -1 && PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Helper to check for object.__setattr__ or __delattr__ applied to a type. @@ -5440,8 +5433,7 @@ wrap_setattr(PyObject *self, PyObject *args, void *wrapped) res = (*func)(self, name, value); if (res < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5459,8 +5451,7 @@ wrap_delattr(PyObject *self, PyObject *args, void *wrapped) res = (*func)(self, name, NULL); if (res < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5571,8 +5562,7 @@ wrap_descr_set(PyObject *self, PyObject *args, void *wrapped) ret = (*func)(self, obj, value); if (ret < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5588,8 +5578,7 @@ wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped) ret = (*func)(self, obj, NULL); if (ret < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5599,8 +5588,7 @@ wrap_init(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds) if (func(self, args, kwds) < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff --git a/Objects/unicodeobject.c b/Objects/unicodeobject.c index b711f0c..0b79c5b 100644 --- a/Objects/unicodeobject.c +++ b/Objects/unicodeobject.c @@ -8254,9 +8254,7 @@ charmapencode_lookup(Py_UCS4 c, PyObject *mapping) if (PyErr_ExceptionMatches(PyExc_LookupError)) { /* No mapping found means: mapping is undefined. */ PyErr_Clear(); - x = Py_None; - Py_INCREF(x); - return x; + Py_RETURN_NONE; } else return NULL; } @@ -262,8 +262,7 @@ static PyObject* fcicreate(PyObject* obj, PyObject* args) if (!FCIDestroy(hfci)) goto err; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; err: if(erf.fError) PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); /* XXX better error type */ @@ -291,8 +290,7 @@ msiobj_close(msiobj* msidb, PyObject *args) { MsiCloseHandle(msidb->h); msidb->h = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -401,8 +399,7 @@ record_cleardata(msiobj* record, PyObject *args) if (status != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -418,8 +415,7 @@ record_setstring(msiobj* record, PyObject *args) if ((status = MsiRecordSetStringW(record->h, field, data)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -435,8 +431,7 @@ record_setstream(msiobj* record, PyObject *args) if ((status = MsiRecordSetStreamW(record->h, field, data)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -452,8 +447,7 @@ record_setinteger(msiobj* record, PyObject *args) if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -617,8 +611,7 @@ summary_setproperty(msiobj* si, PyObject *args) if (status != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -630,8 +623,7 @@ summary_persist(msiobj* si, PyObject *args) status = MsiSummaryInfoPersist(si->h); if (status != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef summary_methods[] = { @@ -714,8 +706,7 @@ view_execute(msiobj *view, PyObject*args) if (status != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -764,8 +755,7 @@ view_modify(msiobj *view, PyObject *args) if ((status = MsiViewModify(view->h, kind, ((msiobj*)data)->h)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* @@ -776,8 +766,7 @@ view_close(msiobj *view, PyObject*args) if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef view_methods[] = { @@ -872,8 +861,7 @@ msidb_commit(msiobj *msidb, PyObject *args) if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* diff --git a/Python/Python-ast.c b/Python/Python-ast.c index e0607ba..a049641 100644 --- a/Python/Python-ast.c +++ b/Python/Python-ast.c @@ -2583,8 +2583,7 @@ ast2obj_mod(void* _o) mod_ty o = (mod_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (o->kind) { @@ -2638,8 +2637,7 @@ ast2obj_stmt(void* _o) stmt_ty o = (stmt_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (o->kind) { @@ -3063,8 +3061,7 @@ ast2obj_expr(void* _o) expr_ty o = (expr_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (o->kind) { @@ -3526,8 +3523,7 @@ ast2obj_slice(void* _o) slice_ty o = (slice_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (o->kind) { @@ -3705,8 +3701,7 @@ ast2obj_comprehension(void* _o) comprehension_ty o = (comprehension_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyType_GenericNew(comprehension_type, NULL, NULL); @@ -3744,8 +3739,7 @@ ast2obj_excepthandler(void* _o) excepthandler_ty o = (excepthandler_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } switch (o->kind) { @@ -3792,8 +3786,7 @@ ast2obj_arguments(void* _o) arguments_ty o = (arguments_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyType_GenericNew(arguments_type, NULL, NULL); @@ -3841,8 +3834,7 @@ ast2obj_arg(void* _o) arg_ty o = (arg_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyType_GenericNew(arg_type, NULL, NULL); @@ -3880,8 +3872,7 @@ ast2obj_keyword(void* _o) keyword_ty o = (keyword_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyType_GenericNew(keyword_type, NULL, NULL); @@ -3909,8 +3900,7 @@ ast2obj_alias(void* _o) alias_ty o = (alias_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyType_GenericNew(alias_type, NULL, NULL); @@ -3938,8 +3928,7 @@ ast2obj_withitem(void* _o) withitem_ty o = (withitem_ty)_o; PyObject *result = NULL, *value = NULL; if (!o) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyType_GenericNew(withitem_type, NULL, NULL); diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c index 3473cc3..2204344 100644 --- a/Python/bltinmodule.c +++ b/Python/bltinmodule.c @@ -1369,8 +1369,7 @@ builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name, { if (PyObject_SetAttr(obj, name, value) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -1392,8 +1391,7 @@ builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name) { if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff --git a/Python/import.c b/Python/import.c index aef1800..38976f6 100644 --- a/Python/import.c +++ b/Python/import.c @@ -260,8 +260,7 @@ _imp_acquire_lock_impl(PyObject *module) #ifdef WITH_THREAD _PyImport_AcquireLock(); #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -283,8 +282,7 @@ _imp_release_lock_impl(PyObject *module) return NULL; } #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } void @@ -1853,8 +1851,7 @@ _imp_init_frozen_impl(PyObject *module, PyObject *name) if (ret < 0) return NULL; if (ret == 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } m = PyImport_AddModuleObject(name); Py_XINCREF(m); diff --git a/Python/modsupport.c b/Python/modsupport.c index 01b5dc9..e9e025b 100644 --- a/Python/modsupport.c +++ b/Python/modsupport.c @@ -514,8 +514,7 @@ va_build_value(const char *format, va_list va, int flags) if (n < 0) return NULL; if (n == 0) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } va_copy(lva, va); if (n == 1) { diff --git a/Python/sysmodule.c b/Python/sysmodule.c index 9c4d9e6..81520ea 100644 --- a/Python/sysmodule.c +++ b/Python/sysmodule.c @@ -179,8 +179,7 @@ sys_displayhook(PyObject *self, PyObject *o) /* After printing, also assign to '_' */ /* Before, set '_' to None to avoid recursion */ if (o == Py_None) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0) return NULL; @@ -211,8 +210,7 @@ sys_displayhook(PyObject *self, PyObject *o) return NULL; if (_PyObject_SetAttrId(builtins, &PyId__, o) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(displayhook_doc, @@ -228,8 +226,7 @@ sys_excepthook(PyObject* self, PyObject* args) if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb)) return NULL; PyErr_Display(exc, value, tb); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(excepthook_doc, @@ -461,8 +458,7 @@ sys_settrace(PyObject *self, PyObject *args) PyEval_SetTrace(NULL, NULL); else PyEval_SetTrace(trace_trampoline, args); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(settrace_doc, @@ -500,8 +496,7 @@ sys_setprofile(PyObject *self, PyObject *args) PyEval_SetProfile(NULL, NULL); else PyEval_SetProfile(profile_trampoline, args); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setprofile_doc, @@ -542,8 +537,7 @@ sys_setcheckinterval(PyObject *self, PyObject *args) return NULL; if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setcheckinterval_doc, @@ -581,8 +575,7 @@ sys_setswitchinterval(PyObject *self, PyObject *args) return NULL; } _PyEval_SetSwitchInterval((unsigned long) (1e6 * d)); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setswitchinterval_doc, @@ -644,8 +637,7 @@ sys_setrecursionlimit(PyObject *self, PyObject *args) } Py_SetRecursionLimit(new_limit); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -1032,8 +1024,7 @@ sys_setdlopenflags(PyObject *self, PyObject *args) if (!tstate) return NULL; tstate->interp->dlopenflags = new_val; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setdlopenflags_doc, @@ -1074,8 +1065,7 @@ sys_mdebug(PyObject *self, PyObject *args) if (!PyArg_ParseTuple(args, "i:mdebug", &flag)) return NULL; mallopt(M_DEBUG, flag); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif /* USE_MALLOPT */ |