diff -r 1756beed417c Modules/_blake2/blake2b_impl.c --- a/Modules/_blake2/blake2b_impl.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_blake2/blake2b_impl.c Sat Dec 17 12:07:00 2016 +0200 @@ -310,8 +310,7 @@ static PyObject * #endif /* !WITH_THREAD */ PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff -r 1756beed417c Modules/_blake2/blake2s_impl.c --- a/Modules/_blake2/blake2s_impl.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_blake2/blake2s_impl.c Sat Dec 17 12:07:00 2016 +0200 @@ -310,8 +310,7 @@ static PyObject * #endif /* !WITH_THREAD */ PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff -r 1756beed417c Modules/_csv.c --- a/Modules/_csv.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_csv.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 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, P 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, { 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 -r 1756beed417c Modules/_ctypes/_ctypes.c --- a/Modules/_ctypes/_ctypes.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_ctypes/_ctypes.c Sat Dec 17 12:07:00 2016 +0200 @@ -156,8 +156,7 @@ static PyObject * 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 *se 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, PyO 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, PyOb 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, PyOb /* 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, PyObj Py_DECREF(mydict); if (res == -1) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* @@ -2825,8 +2819,7 @@ static PyObject * 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 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 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 Py_INCREF(dict->argtypes); return dict->argtypes; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } diff -r 1756beed417c Modules/_ctypes/_ctypes_test.c --- a/Modules/_ctypes/_ctypes_test.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_ctypes/_ctypes_test.c Sat Dec 17 12:07:00 2016 +0200 @@ -363,8 +363,7 @@ PyObject *py_func_si(PyObject *self, PyO 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 -r 1756beed417c Modules/_ctypes/callproc.c --- a/Modules/_ctypes/callproc.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_ctypes/callproc.c Sat Dec 17 12:07:00 2016 +0200 @@ -892,8 +892,7 @@ static PyObject *GetResult(PyObject *res 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 * 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 *s 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 -r 1756beed417c Modules/_ctypes/cfield.c --- a/Modules/_ctypes/cfield.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_ctypes/cfield.c Sat Dec 17 12:07:00 2016 +0200 @@ -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_ssi #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 -r 1756beed417c Modules/_curses_panel.c --- a/Modules/_curses_panel.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_curses_panel.c Sat Dec 17 12:07:00 2016 +0200 @@ -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(PyCur #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 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 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(PyCursesPane } 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( { PyCursesInitialised; update_panels(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Modules/_cursesmodule.c --- a/Modules/_cursesmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_cursesmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -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(PyCursesWindowObje 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 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(PyCursesWi 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(PyObj 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, PyObj 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, 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, PyObjec 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 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, PyObje 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, PyObjec 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 *se 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 -r 1756beed417c Modules/_dbmmodule.c --- a/Modules/_dbmmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_dbmmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -187,8 +187,7 @@ static PyObject * 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 -r 1756beed417c Modules/_gdbmmodule.c --- a/Modules/_gdbmmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_gdbmmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -255,8 +255,7 @@ static PyObject * 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 @@ static PyObject * return v; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -415,8 +413,7 @@ static PyObject * return v; } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } @@ -445,8 +442,7 @@ static PyObject * 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 @@ static PyObject * { check_dbmobject_open(self); gdbm_sync(self->di_dbm); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff -r 1756beed417c Modules/_io/bufferedio.c --- a/Modules/_io/bufferedio.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_io/bufferedio.c Sat Dec 17 12:07:00 2016 +0200 @@ -1689,8 +1689,7 @@ static PyObject * return res; } Py_DECREF(res); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } remaining -= r; written += r; @@ -1714,8 +1713,7 @@ static PyObject * 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 -r 1756beed417c Modules/_lsprof.c --- a/Modules/_lsprof.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_lsprof.c Sat Dec 17 12:07:00 2016 +0200 @@ -692,8 +692,7 @@ profiler_enable(ProfilerObject *self, Py 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, P 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 -r 1756beed417c Modules/_operator.c --- a/Modules/_operator.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_operator.c Sat Dec 17 12:07:00 2016 +0200 @@ -27,15 +27,13 @@ used for special methods; variants witho PyObject *a1, *a2; \ if(! PyArg_UnpackTuple(a,#OP,2,2,&a1,&a2)) return NULL; \ if(-1 == AOP(a1,a2)) return NULL; \ - Py_INCREF(Py_None); \ - return Py_None; } + Py_RETURN_NONE; } #define spam3n(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a) { \ PyObject *a1, *a2, *a3; \ if(! PyArg_UnpackTuple(a,#OP,3,3,&a1,&a2,&a3)) return NULL; \ if(-1 == AOP(a1,a2,a3)) return NULL; \ - Py_INCREF(Py_None); \ - return Py_None; } + Py_RETURN_NONE; } #define spami(OP,AOP) static PyObject *OP(PyObject *s, PyObject *a1) { \ long r; \ diff -r 1756beed417c Modules/_randommodule.c --- a/Modules/_randommodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_randommodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -376,8 +376,7 @@ random_setstate(RandomObject *self, PyOb } self->index = (int)index; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff -r 1756beed417c Modules/_scproxy.c --- a/Modules/_scproxy.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_scproxy.c Sat Dec 17 12:07:00 2016 +0200 @@ -64,8 +64,7 @@ get_proxy_settings(PyObject* mod __attri proxyDict = SCDynamicStoreCopyProxies(NULL); if (!proxyDict) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } result = PyDict_New(); diff -r 1756beed417c Modules/_sha3/sha3module.c --- a/Modules/_sha3/sha3module.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_sha3/sha3module.c Sat Dec 17 12:07:00 2016 +0200 @@ -403,8 +403,7 @@ static PyObject * } PyBuffer_Release(&buf); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Modules/_sqlite/connection.c --- a/Modules/_sqlite/connection.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_sqlite/connection.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 -r 1756beed417c Modules/_sre.c --- a/Modules/_sre.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_sre.c Sat Dec 17 12:07:00 2016 +0200 @@ -481,8 +481,7 @@ state_getslice(SRE_STATE* state, Py_ssiz /* 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]); @@ -2425,8 +2424,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 * @@ -2440,8 +2438,7 @@ match_lastgroup_get(MatchObject *self) return result; PyErr_Clear(); } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -2523,8 +2520,7 @@ pattern_new_match(PatternObject* pattern } else if (status == 0) { /* no match */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Modules/_ssl.c --- a/Modules/_ssl.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_ssl.c Sat Dec 17 12:07:00 2016 +0200 @@ -755,8 +755,7 @@ static PyObject * 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 @@ static PyObject * buf += written; len -= written; } while (len); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff -r 1756beed417c Modules/_testcapimodule.c --- a/Modules/_testcapimodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_testcapimodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 *se 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 */ @@ -2097,8 +2089,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). */ @@ -2315,11 +2306,9 @@ PyObject *pending_threadfunc(PyObject *s 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 @@ -2705,8 +2694,7 @@ profile_int(PyObject *self, PyObject* ar Py_DECREF(op1); print_delta(7, &start, &stop); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif diff -r 1756beed417c Modules/_testmultiphase.c --- a/Modules/_testmultiphase.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_testmultiphase.c Sat Dec 17 12:07:00 2016 +0200 @@ -36,8 +36,7 @@ Example_demo(ExampleObject *self, PyObje Py_INCREF(o); return o; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Modules/_threadmodule.c --- a/Modules/_threadmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/_threadmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -180,8 +180,7 @@ lock_PyThread_release_lock(lockobject *s 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 -r 1756beed417c Modules/arraymodule.c --- a/Modules/arraymodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/arraymodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -1007,8 +1007,7 @@ ins(arrayobject *self, Py_ssize_t where, { 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, Py 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, Py { 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 *s "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 *se } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1453,8 +1448,7 @@ array_array_tofile(arrayobject *self, Py } done: - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1491,8 +1485,7 @@ array_array_fromlist(arrayobject *self, } } } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -1557,8 +1550,7 @@ frombytes(arrayobject *self, Py_buffer * buffer->buf, n * itemsize); } PyBuffer_Release(buffer); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] diff -r 1756beed417c Modules/faulthandler.c --- a/Modules/faulthandler.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/faulthandler.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 -r 1756beed417c Modules/fpectlmodule.c --- a/Modules/fpectlmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/fpectlmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -102,8 +102,7 @@ static PyObject *turnon_sigfpe(PyObject /* 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 #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 -r 1756beed417c Modules/fpetestmodule.c --- a/Modules/fpetestmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/fpetestmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -95,8 +95,7 @@ static PyObject *test(PyObject *self,PyO r = nest2(2, 2.0); printerr(r); - Py_INCREF (Py_None); - return Py_None; + Py_RETURN_NONE; } static void printerr(double r) diff -r 1756beed417c Modules/gcmodule.c --- a/Modules/gcmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/gcmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 *a 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 * generations[i].threshold = generations[2].threshold; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(gc_get_thresh__doc__, diff -r 1756beed417c Modules/md5module.c --- a/Modules/md5module.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/md5module.c Sat Dec 17 12:07:00 2016 +0200 @@ -416,8 +416,7 @@ MD5Type_update(MD5object *self, PyObject 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 -r 1756beed417c Modules/mmapmodule.c --- a/Modules/mmapmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/mmapmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -181,8 +181,7 @@ mmap_close_method(mmap_object *self, PyO } #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, PyOb 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, PyOb memmove(&self->data[dest], &self->data[src], cnt); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; bounds: PyErr_SetString(PyExc_ValueError, diff -r 1756beed417c Modules/ossaudiodev.c --- a/Modules/ossaudiodev.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/ossaudiodev.c Sat Dec 17 12:07:00 2016 +0200 @@ -307,8 +307,7 @@ static PyObject * 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 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 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 *u 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, PyObj close(self->fd); self->fd = -1; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff -r 1756beed417c Modules/parsermodule.c --- a/Modules/parsermodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/parsermodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -91,8 +91,7 @@ node2tuple(node *n, PyObject *result = NULL, *w; if (n == NULL) { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } if (ISNONTERMINAL(TYPE(n))) { diff -r 1756beed417c Modules/posixmodule.c --- a/Modules/posixmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/posixmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -1868,8 +1868,7 @@ stat_float_times(PyObject* self, PyObjec /* 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; @@ -6190,8 +6189,7 @@ posix_initgroups(PyObject *self, PyObjec if (res == -1) return PyErr_SetFromErrno(PyExc_OSError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif /* HAVE_INITGROUPS */ @@ -6254,8 +6252,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 */ @@ -6581,8 +6578,7 @@ os_setreuid_impl(PyObject *module, uid_t if (setreuid(ruid, euid) < 0) { return posix_error(); } else { - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } } #endif /* HAVE_SETREUID */ @@ -6677,8 +6673,7 @@ os_setgroups(PyObject *module, PyObject if (setgroups(len, grouplist) < 0) return posix_error(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } #endif /* HAVE_SETGROUPS */ diff -r 1756beed417c Modules/pyexpat.c --- a/Modules/pyexpat.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/pyexpat.c Sat Dec 17 12:07:00 2016 +0200 @@ -161,8 +161,7 @@ conv_string_to_unicode(const XML_Char *s 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_Cha 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(xml 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, 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 -r 1756beed417c Modules/resource.c --- a/Modules/resource.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/resource.c Sat Dec 17 12:07:00 2016 +0200 @@ -210,8 +210,7 @@ resource_setrlimit(PyObject *self, PyObj goto error; } Py_DECREF(limits); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; error: Py_DECREF(limits); diff -r 1756beed417c Modules/selectmodule.c --- a/Modules/selectmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/selectmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -431,8 +431,7 @@ poll_register(pollObject *self, PyObject 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 * self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -513,8 +511,7 @@ poll_unregister(pollObject *self, PyObje Py_DECREF(key); self->ufd_uptodate = 0; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(poll_poll_doc, diff -r 1756beed417c Modules/sha1module.c --- a/Modules/sha1module.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/sha1module.c Sat Dec 17 12:07:00 2016 +0200 @@ -393,8 +393,7 @@ SHA1Type_update(SHA1object *self, PyObje 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 -r 1756beed417c Modules/sha256module.c --- a/Modules/sha256module.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/sha256module.c Sat Dec 17 12:07:00 2016 +0200 @@ -483,8 +483,7 @@ SHA256Type_update(SHAobject *self, PyObj 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 -r 1756beed417c Modules/sha512module.c --- a/Modules/sha512module.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/sha512module.c Sat Dec 17 12:07:00 2016 +0200 @@ -548,8 +548,7 @@ SHA512Type_update(SHAobject *self, PyObj 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 -r 1756beed417c Modules/socketmodule.c --- a/Modules/socketmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/socketmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -1218,8 +1218,7 @@ makesockaddr(SOCKET_T sockfd, struct soc { 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, PyObjec 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, PyObj Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(listen_doc, @@ -4361,8 +4356,7 @@ sock_shutdown(PySocketSockObject *s, PyO Py_END_ALLOW_THREADS if (res < 0) return s->errorhandler(); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(shutdown_doc, @@ -6194,8 +6188,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); @@ -6220,8 +6213,7 @@ socket_setdefaulttimeout(PyObject *self, defaulttimeout = timeout; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(setdefaulttimeout_doc, diff -r 1756beed417c Modules/syslogmodule.c --- a/Modules/syslogmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/syslogmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -147,8 +147,7 @@ syslog_openlog(PyObject * self, PyObject 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 Py_CLEAR(S_ident_o); S_log_open = 0; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff -r 1756beed417c Modules/termios.c --- a/Modules/termios.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/termios.c Sat Dec 17 12:07:00 2016 +0200 @@ -194,8 +194,7 @@ termios_tcsetattr(PyObject *self, PyObje 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, PyOb 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 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 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 if (tcflow(fd, action) == -1) return PyErr_SetFromErrno(TermiosError); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef termios_methods[] = diff -r 1756beed417c Modules/timemodule.c --- a/Modules/timemodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/timemodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 *unu if (PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } PyDoc_STRVAR(tzset_doc, diff -r 1756beed417c Modules/xxlimited.c --- a/Modules/xxlimited.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/xxlimited.c Sat Dec 17 12:07:00 2016 +0200 @@ -65,8 +65,7 @@ Xxo_demo(XxoObject *self, PyObject *args Py_INCREF(o); return o; } - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef Xxo_methods[] = { @@ -170,8 +169,7 @@ xx_roj(PyObject *self, PyObject *args) long b; if (!PyArg_ParseTuple(args, "O#:roj", &a, &b)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Modules/xxmodule.c --- a/Modules/xxmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/xxmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -52,8 +52,7 @@ Xxo_demo(XxoObject *self, PyObject *args { if (!PyArg_ParseTuple(args, ":demo")) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef Xxo_methods[] = { @@ -192,8 +191,7 @@ xx_bug(PyObject *self, PyObject *args) printf("\n"); /* Py_DECREF(item); */ - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /* Test bad format character */ @@ -205,8 +203,7 @@ xx_roj(PyObject *self, PyObject *args) long b; if (!PyArg_ParseTuple(args, "O#:roj", &a, &b)) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Modules/xxsubtype.c --- a/Modules/xxsubtype.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/xxsubtype.c Sat Dec 17 12:07:00 2016 +0200 @@ -39,8 +39,7 @@ spamlist_setstate(spamlistobject *self, if (!PyArg_ParseTuple(args, "i:setstate", &state)) return NULL; self->state = state; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -164,8 +163,7 @@ spamdict_setstate(spamdictobject *self, if (!PyArg_ParseTuple(args, "i:setstate", &state)) return NULL; self->state = state; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyMethodDef spamdict_methods[] = { diff -r 1756beed417c Modules/zipimport.c --- a/Modules/zipimport.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Modules/zipimport.c Sat Dec 17 12:07:00 2016 +0200 @@ -677,8 +677,7 @@ zipimporter_get_source(PyObject *obj, Py } /* 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, PyObj 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, PyObj 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 -r 1756beed417c Objects/descrobject.c --- a/Objects/descrobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/descrobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -421,8 +421,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); } @@ -437,8 +436,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 -r 1756beed417c Objects/exceptions.c --- a/Objects/exceptions.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/exceptions.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 -r 1756beed417c Objects/fileobject.c --- a/Objects/fileobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/fileobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 -r 1756beed417c Objects/funcobject.c --- a/Objects/funcobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/funcobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 -r 1756beed417c Objects/genobject.c --- a/Objects/genobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/genobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -402,8 +402,7 @@ gen_close(PyGenObject *gen, PyObject *ar 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 -r 1756beed417c Objects/listobject.c --- a/Objects/listobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/listobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -2281,12 +2281,10 @@ list_richcompare(PyObject *v, PyObject * /* 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 -r 1756beed417c Objects/tupleobject.c --- a/Objects/tupleobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/tupleobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -631,12 +631,10 @@ tuplerichcompare(PyObject *v, PyObject * /* 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 -r 1756beed417c Objects/typeobject.c --- a/Objects/typeobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/typeobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -140,8 +140,7 @@ PyObject * 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 @@ PyObject * 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); } @@ -5335,8 +5332,7 @@ wrap_sq_setitem(PyObject *self, PyObject res = (*func)(self, i, value); if (res == -1 && PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5356,8 +5352,7 @@ wrap_sq_delitem(PyObject *self, PyObject 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 */ @@ -5390,8 +5385,7 @@ wrap_objobjargproc(PyObject *self, PyObj res = (*func)(self, key, value); if (res == -1 && PyErr_Occurred()) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5407,8 +5401,7 @@ wrap_delitem(PyObject *self, PyObject *a 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. @@ -5445,8 +5438,7 @@ wrap_setattr(PyObject *self, PyObject *a res = (*func)(self, name, value); if (res < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5464,8 +5456,7 @@ wrap_delattr(PyObject *self, PyObject *a res = (*func)(self, name, NULL); if (res < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5576,8 +5567,7 @@ wrap_descr_set(PyObject *self, PyObject ret = (*func)(self, obj, value); if (ret < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5593,8 +5583,7 @@ wrap_descr_delete(PyObject *self, PyObje ret = (*func)(self, obj, NULL); if (ret < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -5604,8 +5593,7 @@ wrap_init(PyObject *self, PyObject *args if (func(self, args, kwds) < 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * diff -r 1756beed417c Objects/unicodeobject.c --- a/Objects/unicodeobject.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Objects/unicodeobject.c Sat Dec 17 12:07:00 2016 +0200 @@ -8238,9 +8238,7 @@ charmapencode_lookup(Py_UCS4 c, PyObject 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; } diff -r 1756beed417c PC/_msi.c --- a/PC/_msi.c Sat Dec 17 09:19:11 2016 +0100 +++ b/PC/_msi.c Sat Dec 17 12:07:00 2016 +0200 @@ -262,8 +262,7 @@ static PyObject* fcicreate(PyObject* obj 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 *ar { 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, PyObjec 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, PyObjec 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, PyObjec 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, PyObje 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 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 *ar 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 *ar if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS) return msierror(status); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject* diff -r 1756beed417c Python/Python-ast.c --- a/Python/Python-ast.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Python/Python-ast.c Sat Dec 17 12:07:00 2016 +0200 @@ -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 -r 1756beed417c Python/bltinmodule.c --- a/Python/bltinmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Python/bltinmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -1364,8 +1364,7 @@ builtin_setattr_impl(PyObject *module, P { if (PyObject_SetAttr(obj, name, value) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } @@ -1387,8 +1386,7 @@ builtin_delattr_impl(PyObject *module, P { if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0) return NULL; - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } diff -r 1756beed417c Python/import.c --- a/Python/import.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Python/import.c Sat Dec 17 12:07:00 2016 +0200 @@ -260,8 +260,7 @@ static PyObject * #ifdef WITH_THREAD _PyImport_AcquireLock(); #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } /*[clinic input] @@ -283,8 +282,7 @@ static PyObject * return NULL; } #endif - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } void @@ -1853,8 +1851,7 @@ static PyObject * 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 -r 1756beed417c Python/modsupport.c --- a/Python/modsupport.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Python/modsupport.c Sat Dec 17 12:07:00 2016 +0200 @@ -514,8 +514,7 @@ va_build_value(const char *format, va_li 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 -r 1756beed417c Python/sysmodule.c --- a/Python/sysmodule.c Sat Dec 17 09:19:11 2016 +0100 +++ b/Python/sysmodule.c Sat Dec 17 12:07:00 2016 +0200 @@ -179,8 +179,7 @@ sys_displayhook(PyObject *self, PyObject /* 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 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* 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 *a 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 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, PyO 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, Py 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, Py } Py_SetRecursionLimit(new_limit); - Py_INCREF(Py_None); - return Py_None; + Py_RETURN_NONE; } static PyObject * @@ -1032,8 +1024,7 @@ sys_setdlopenflags(PyObject *self, PyObj 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 *arg 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 */