Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever

possible.  Patch is writen with Coccinelle.
This commit is contained in:
Serhiy Storchaka 2017-01-23 09:47:21 +02:00
parent 60e6e962ba
commit 228b12edcc
57 changed files with 225 additions and 445 deletions

View File

@ -310,8 +310,7 @@ _blake2b_blake2b_update(BLAKE2bObject *self, PyObject *obj)
#endif /* !WITH_THREAD */ #endif /* !WITH_THREAD */
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]

View File

@ -310,8 +310,7 @@ _blake2s_blake2s_update(BLAKE2sObject *self, PyObject *obj)
#endif /* !WITH_THREAD */ #endif /* !WITH_THREAD */
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]

View File

@ -152,8 +152,7 @@ static PyObject *
get_nullchar_as_None(Py_UCS4 c) get_nullchar_as_None(Py_UCS4 c)
{ {
if (c == '\0') { if (c == '\0') {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
else else
return PyUnicode_FromOrdinal(c); return PyUnicode_FromOrdinal(c);
@ -1294,8 +1293,7 @@ csv_writerows(WriterObj *self, PyObject *seqseq)
Py_DECREF(row_iter); Py_DECREF(row_iter);
if (PyErr_Occurred()) if (PyErr_Occurred())
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static struct PyMethodDef Writer_methods[] = { static struct PyMethodDef Writer_methods[] = {
@ -1450,8 +1448,7 @@ csv_register_dialect(PyObject *module, PyObject *args, PyObject *kwargs)
return NULL; return NULL;
} }
Py_DECREF(dialect); Py_DECREF(dialect);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -1459,8 +1456,7 @@ csv_unregister_dialect(PyObject *module, PyObject *name_obj)
{ {
if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0) if (PyDict_DelItem(_csvstate_global->dialects, name_obj) < 0)
return PyErr_Format(_csvstate_global->error_obj, "unknown dialect"); return PyErr_Format(_csvstate_global->error_obj, "unknown dialect");
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -156,8 +156,7 @@ _DictRemover_call(PyObject *myself, PyObject *args, PyObject *kw)
Py_CLEAR(self->key); Py_CLEAR(self->key);
Py_CLEAR(self->dict); Py_CLEAR(self->dict);
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyTypeObject DictRemover_Type = { static PyTypeObject DictRemover_Type = {
@ -979,8 +978,7 @@ PyCPointerType_set_type(PyTypeObject *self, PyObject *type)
if (-1 == PyDict_SetItemString((PyObject *)dict, "_type_", type)) if (-1 == PyDict_SetItemString((PyObject *)dict, "_type_", type))
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject *_byref(PyObject *); static PyObject *_byref(PyObject *);
@ -1496,8 +1494,7 @@ c_wchar_p_from_param(PyObject *type, PyObject *value)
PyObject *as_parameter; PyObject *as_parameter;
int res; int res;
if (value == Py_None) { if (value == Py_None) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if (PyUnicode_Check(value)) { if (PyUnicode_Check(value)) {
PyCArgObject *parg; PyCArgObject *parg;
@ -1561,8 +1558,7 @@ c_char_p_from_param(PyObject *type, PyObject *value)
PyObject *as_parameter; PyObject *as_parameter;
int res; int res;
if (value == Py_None) { if (value == Py_None) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if (PyBytes_Check(value)) { if (PyBytes_Check(value)) {
PyCArgObject *parg; PyCArgObject *parg;
@ -1629,8 +1625,7 @@ c_void_p_from_param(PyObject *type, PyObject *value)
/* None */ /* None */
if (value == Py_None) { if (value == Py_None) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* Should probably allow buffer interface as well */ /* Should probably allow buffer interface as well */
/* int, long */ /* int, long */
@ -2602,8 +2597,7 @@ PyCData_setstate(PyObject *myself, PyObject *args)
Py_DECREF(mydict); Py_DECREF(mydict);
if (res == -1) if (res == -1)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* /*
@ -2825,8 +2819,7 @@ _PyCData_set(CDataObject *dst, PyObject *type, SETFUNC setfunc, PyObject *value,
return result; return result;
} else if (value == Py_None && PyCPointerTypeObject_Check(type)) { } else if (value == Py_None && PyCPointerTypeObject_Check(type)) {
*(void **)ptr = NULL; *(void **)ptr = NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} else { } else {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
"expected %s instance, got %s", "expected %s instance, got %s",
@ -2980,8 +2973,7 @@ PyCFuncPtr_get_errcheck(PyCFuncPtrObject *self)
Py_INCREF(self->errcheck); Py_INCREF(self->errcheck);
return self->errcheck; return self->errcheck;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static int static int
@ -3019,8 +3011,7 @@ PyCFuncPtr_get_restype(PyCFuncPtrObject *self)
Py_INCREF(dict->restype); Py_INCREF(dict->restype);
return dict->restype; return dict->restype;
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
@ -3057,8 +3048,7 @@ PyCFuncPtr_get_argtypes(PyCFuncPtrObject *self)
Py_INCREF(dict->argtypes); Py_INCREF(dict->argtypes);
return dict->argtypes; return dict->argtypes;
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }

View File

@ -363,8 +363,7 @@ PyObject *py_func_si(PyObject *self, PyObject *args)
int i; int i;
if (!PyArg_ParseTuple(args, "si", &name, &i)) if (!PyArg_ParseTuple(args, "si", &name, &i))
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
EXPORT(void) _py_func_si(char *s, int i) 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) PyObject *py_func(PyObject *self, PyObject *args)
{ {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
EXPORT(void) _py_func(void) EXPORT(void) _py_func(void)

View File

@ -892,8 +892,7 @@ static PyObject *GetResult(PyObject *restype, void *result, PyObject *checker)
return PyLong_FromLong(*(int *)result); return PyLong_FromLong(*(int *)result);
if (restype == Py_None) { if (restype == Py_None) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
dict = PyType_stgdict(restype); dict = PyType_stgdict(restype);
@ -1263,8 +1262,7 @@ static PyObject *free_library(PyObject *self, PyObject *args)
return NULL; return NULL;
if (!FreeLibrary((HMODULE)hMod)) if (!FreeLibrary((HMODULE)hMod))
return PyErr_SetFromWindowsErr(GetLastError()); return PyErr_SetFromWindowsErr(GetLastError());
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static const char copy_com_pointer_doc[] = static const char copy_com_pointer_doc[] =
@ -1349,8 +1347,7 @@ static PyObject *py_dl_close(PyObject *self, PyObject *args)
ctypes_dlerror()); ctypes_dlerror());
return NULL; return NULL;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject *py_dl_sym(PyObject *self, PyObject *args) static PyObject *py_dl_sym(PyObject *self, PyObject *args)
@ -1624,8 +1621,7 @@ resize(PyObject *self, PyObject *args)
obj->b_size = size; obj->b_size = size;
} }
done: done:
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -1337,8 +1337,7 @@ z_get(void *ptr, Py_ssize_t size)
return PyBytes_FromStringAndSize(*(char **)ptr, return PyBytes_FromStringAndSize(*(char **)ptr,
strlen(*(char **)ptr)); strlen(*(char **)ptr));
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
@ -1360,8 +1359,7 @@ Z_set(void *ptr, PyObject *value, Py_ssize_t size)
#else #else
*(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value); *(wchar_t **)ptr = (wchar_t *)PyLong_AsUnsignedLongMask(value);
#endif #endif
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if (!PyUnicode_Check(value)) { if (!PyUnicode_Check(value)) {
PyErr_Format(PyExc_TypeError, PyErr_Format(PyExc_TypeError,
@ -1392,8 +1390,7 @@ Z_get(void *ptr, Py_ssize_t size)
if (p) { if (p) {
return PyUnicode_FromWideChar(p, wcslen(p)); return PyUnicode_FromWideChar(p, wcslen(p));
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
#endif #endif
@ -1452,8 +1449,7 @@ BSTR_get(void *ptr, Py_ssize_t size)
/* Hm, it seems NULL pointer and zero length string are the /* Hm, it seems NULL pointer and zero length string are the
same in BSTR, see Don Box, p 81 same in BSTR, see Don Box, p 81
*/ */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
#endif #endif
@ -1493,8 +1489,7 @@ static PyObject *
P_get(void *ptr, Py_ssize_t size) P_get(void *ptr, Py_ssize_t size)
{ {
if (*(void **)ptr == NULL) { if (*(void **)ptr == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyLong_FromVoidPtr(*(void **)ptr); return PyLong_FromVoidPtr(*(void **)ptr);
} }

View File

@ -59,8 +59,7 @@ static PyObject *
PyCursesCheckERR(int code, const char *fname) PyCursesCheckERR(int code, const char *fname)
{ {
if (code != ERR) { if (code != ERR) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} else { } else {
if (fname == NULL) { if (fname == NULL) {
PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR); PyErr_SetString(_curses_panelstate_global->PyCursesError, catchall_ERR);
@ -177,8 +176,8 @@ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
#define Panel_NoArgTrueFalseFunction(X) \ #define Panel_NoArgTrueFalseFunction(X) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \ static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self) \
{ \ { \
if (X (self->pan) == FALSE) { Py_INCREF(Py_False); return Py_False; } \ if (X (self->pan) == FALSE) { Py_RETURN_FALSE; } \
else { Py_INCREF(Py_True); return Py_True; } } else { Py_RETURN_TRUE; } }
#define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \ #define Panel_TwoArgNoReturnFunction(X, TYPE, PARSESTR) \
static PyObject *PyCursesPanel_##X(PyCursesPanelObject *self, PyObject *args) \ 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 if (pan == NULL) { /* valid output, it means the calling panel
is on top of the stack */ is on top of the stack */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
po = find_po(pan); po = find_po(pan);
if (po == NULL) { if (po == NULL) {
@ -270,8 +268,7 @@ PyCursesPanel_below(PyCursesPanelObject *self)
if (pan == NULL) { /* valid output, it means the calling panel if (pan == NULL) { /* valid output, it means the calling panel
is on the bottom of the stack */ is on the bottom of the stack */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
po = find_po(pan); po = find_po(pan);
if (po == NULL) { if (po == NULL) {
@ -319,8 +316,7 @@ PyCursesPanel_replace_panel(PyCursesPanelObject *self, PyObject *args)
} }
Py_INCREF(temp); Py_INCREF(temp);
Py_SETREF(po->wo, temp); Py_SETREF(po->wo, temp);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -406,8 +402,7 @@ PyCurses_bottom_panel(PyObject *self)
if (pan == NULL) { /* valid output, it means if (pan == NULL) { /* valid output, it means
there's no panel at all */ there's no panel at all */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
po = find_po(pan); po = find_po(pan);
if (po == NULL) { if (po == NULL) {
@ -452,8 +447,7 @@ PyCurses_top_panel(PyObject *self)
if (pan == NULL) { /* valid output, it means if (pan == NULL) { /* valid output, it means
there's no panel at all */ there's no panel at all */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
po = find_po(pan); po = find_po(pan);
if (po == NULL) { if (po == NULL) {
@ -469,8 +463,7 @@ static PyObject *PyCurses_update_panels(PyObject *self)
{ {
PyCursesInitialised; PyCursesInitialised;
update_panels(); update_panels();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }

View File

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

View File

@ -187,8 +187,7 @@ _dbm_dbm_close_impl(dbmobject *self)
if (self->di_dbm) if (self->di_dbm)
dbm_close(self->di_dbm); dbm_close(self->di_dbm);
self->di_dbm = NULL; self->di_dbm = NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]

View File

@ -255,8 +255,7 @@ _gdbm_gdbm_close_impl(dbmobject *self)
if (self->di_dbm) if (self->di_dbm)
gdbm_close(self->di_dbm); gdbm_close(self->di_dbm);
self->di_dbm = NULL; self->di_dbm = NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* XXX Should return a set or a set view */ /* XXX Should return a set or a set view */
@ -375,8 +374,7 @@ _gdbm_gdbm_firstkey_impl(dbmobject *self)
return v; return v;
} }
else { else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
@ -415,8 +413,7 @@ _gdbm_gdbm_nextkey_impl(dbmobject *self, const char *key,
return v; return v;
} }
else { else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
@ -445,8 +442,7 @@ _gdbm_gdbm_reorganize_impl(dbmobject *self)
PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno)); PyErr_SetString(DbmError, gdbm_strerror(gdbm_errno));
return NULL; return NULL;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -464,8 +460,7 @@ _gdbm_gdbm_sync_impl(dbmobject *self)
{ {
check_dbmobject_open(self); check_dbmobject_open(self);
gdbm_sync(self->di_dbm); gdbm_sync(self->di_dbm);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -1689,8 +1689,7 @@ _bufferedreader_read_generic(buffered *self, Py_ssize_t n)
return res; return res;
} }
Py_DECREF(res); Py_DECREF(res);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
remaining -= r; remaining -= r;
written += r; written += r;
@ -1714,8 +1713,7 @@ _bufferedreader_read_generic(buffered *self, Py_ssize_t n)
return res; return res;
} }
Py_DECREF(res); Py_DECREF(res);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if (remaining > r) { if (remaining > r) {
memcpy(out + written, self->buffer + self->pos, r); memcpy(out + written, self->buffer + self->pos, r);

View File

@ -692,8 +692,7 @@ profiler_enable(ProfilerObject *self, PyObject *args, PyObject *kwds)
return NULL; return NULL;
PyEval_SetProfile(profiler_callback, (PyObject*)self); PyEval_SetProfile(profiler_callback, (PyObject*)self);
self->flags |= POF_ENABLED; self->flags |= POF_ENABLED;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static void static void
@ -726,8 +725,7 @@ profiler_disable(ProfilerObject *self, PyObject* noarg)
flush_unmatched(self); flush_unmatched(self);
if (pending_exception(self)) if (pending_exception(self))
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(clear_doc, "\ PyDoc_STRVAR(clear_doc, "\
@ -740,8 +738,7 @@ static PyObject*
profiler_clear(ProfilerObject *pObj, PyObject* noarg) profiler_clear(ProfilerObject *pObj, PyObject* noarg)
{ {
clearEntries(pObj); clearEntries(pObj);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static void static void

View File

@ -376,8 +376,7 @@ random_setstate(RandomObject *self, PyObject *state)
} }
self->index = (int)index; self->index = (int)index;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -64,8 +64,7 @@ get_proxy_settings(PyObject* mod __attribute__((__unused__)))
proxyDict = SCDynamicStoreCopyProxies(NULL); proxyDict = SCDynamicStoreCopyProxies(NULL);
if (!proxyDict) { if (!proxyDict) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyDict_New(); result = PyDict_New();

View File

@ -403,8 +403,7 @@ _sha3_sha3_224_update(SHA3object *self, PyObject *obj)
} }
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }

View File

@ -400,8 +400,7 @@ error:
if (PyErr_Occurred()) { if (PyErr_Occurred()) {
return NULL; return NULL;
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
@ -443,8 +442,7 @@ error:
if (PyErr_Occurred()) { if (PyErr_Occurred()) {
return NULL; return NULL;
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
@ -487,8 +485,7 @@ error:
if (PyErr_Occurred()) { if (PyErr_Occurred()) {
return NULL; return NULL;
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }

View File

@ -481,8 +481,7 @@ state_getslice(SRE_STATE* state, Py_ssize_t index, PyObject* string, int empty)
/* want empty string */ /* want empty string */
i = j = 0; i = j = 0;
else { else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} else { } else {
i = STATE_OFFSET(state, state->mark[index]); i = STATE_OFFSET(state, state->mark[index]);
@ -2368,8 +2367,7 @@ match_lastindex_get(MatchObject *self)
{ {
if (self->lastindex >= 0) if (self->lastindex >= 0)
return PyLong_FromSsize_t(self->lastindex); return PyLong_FromSsize_t(self->lastindex);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -2383,8 +2381,7 @@ match_lastgroup_get(MatchObject *self)
return result; return result;
PyErr_Clear(); PyErr_Clear();
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -2466,8 +2463,7 @@ pattern_new_match(PatternObject* pattern, SRE_STATE* state, Py_ssize_t status)
} else if (status == 0) { } else if (status == 0) {
/* no match */ /* no match */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }

View File

@ -755,8 +755,7 @@ _ssl__SSLSocket_do_handshake_impl(PySSLSocket *self)
PySSL_END_ALLOW_THREADS PySSL_END_ALLOW_THREADS
self->handshake_done = 1; self->handshake_done = 1;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
error: error:
Py_XDECREF(sock); Py_XDECREF(sock);
@ -4500,8 +4499,7 @@ _ssl_RAND_add_impl(PyObject *module, Py_buffer *view, double entropy)
buf += written; buf += written;
len -= written; len -= written;
} while (len); } while (len);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -64,8 +64,7 @@ test_config(PyObject *self)
#undef CHECK_SIZEOF #undef CHECK_SIZEOF
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -169,8 +168,7 @@ test_list_api(PyObject *self)
Py_DECREF(list); Py_DECREF(list);
#undef NLIST #undef NLIST
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static int static int
@ -234,8 +232,7 @@ test_dict_iteration(PyObject* self)
} }
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -614,8 +611,7 @@ test_long_and_overflow(PyObject *self)
return raiseTestError("test_long_and_overflow", return raiseTestError("test_long_and_overflow",
"overflow was not cleared"); "overflow was not cleared");
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* Test the PyLong_AsLongLongAndOverflow API. General conversion to /* 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", return raiseTestError("test_long_long_and_overflow",
"overflow was not cleared"); "overflow was not cleared");
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* Test the PyLong_As{Size,Ssize}_t API. At present this just tests that /* 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"); "L code returned wrong value for int 42");
Py_DECREF(tuple); Py_DECREF(tuple);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -1224,8 +1218,7 @@ test_k_code(PyObject *self)
"k code returned wrong value for long -0xFFF..000042"); "k code returned wrong value for long -0xFFF..000042");
Py_DECREF(tuple); Py_DECREF(tuple);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -1672,8 +1665,7 @@ test_u_code(PyObject *self)
"u# code returned wrong values for u'test'"); "u# code returned wrong values for u'test'");
Py_DECREF(tuple); Py_DECREF(tuple);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* Test Z and Z# codes for PyArg_ParseTuple */ /* Test Z and Z# codes for PyArg_ParseTuple */
@ -2118,8 +2110,7 @@ test_long_numbits(PyObject *self)
return raiseTestError("test_long_numbits", return raiseTestError("test_long_numbits",
"wrong result for _PyLong_Sign"); "wrong result for _PyLong_Sign");
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* Example passing NULLs to PyObject_Str(NULL). */ /* Example passing NULLs to PyObject_Str(NULL). */
@ -2336,11 +2327,9 @@ PyObject *pending_threadfunc(PyObject *self, PyObject *arg)
if (r<0) { if (r<0) {
Py_DECREF(callable); /* unsuccessful add, destroy the extra reference */ Py_DECREF(callable); /* unsuccessful add, destroy the extra reference */
Py_INCREF(Py_False); Py_RETURN_FALSE;
return Py_False;
} }
Py_INCREF(Py_True); Py_RETURN_TRUE;
return Py_True;
} }
#endif #endif
@ -2726,8 +2715,7 @@ profile_int(PyObject *self, PyObject* args)
Py_DECREF(op1); Py_DECREF(op1);
print_delta(7, &start, &stop); print_delta(7, &start, &stop);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#endif #endif

View File

@ -36,8 +36,7 @@ Example_demo(ExampleObject *self, PyObject *args)
Py_INCREF(o); Py_INCREF(o);
return o; return o;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }

View File

@ -180,8 +180,7 @@ lock_PyThread_release_lock(lockobject *self)
PyThread_release_lock(self->lock_lock); PyThread_release_lock(self->lock_lock);
self->locked = 0; self->locked = 0;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(release_doc, PyDoc_STRVAR(release_doc,
@ -1111,8 +1110,7 @@ static PyObject *
thread_PyThread_interrupt_main(PyObject * self) thread_PyThread_interrupt_main(PyObject * self)
{ {
PyErr_SetInterrupt(); PyErr_SetInterrupt();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(interrupt_doc, PyDoc_STRVAR(interrupt_doc,

View File

@ -1007,8 +1007,7 @@ ins(arrayobject *self, Py_ssize_t where, PyObject *v)
{ {
if (ins1(self, where, v) != 0) if (ins1(self, where, v) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -1122,8 +1121,7 @@ array_array_remove(arrayobject *self, PyObject *v)
if (cmp > 0) { if (cmp > 0) {
if (array_del_slice(self, i, i+1) != 0) if (array_del_slice(self, i, i+1) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
else if (cmp < 0) else if (cmp < 0)
return NULL; return NULL;
@ -1185,8 +1183,7 @@ array_array_extend(arrayobject *self, PyObject *bb)
{ {
if (array_do_extend(self, bb) == -1) if (array_do_extend(self, bb) == -1)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -1315,8 +1312,7 @@ array_array_byteswap_impl(arrayobject *self)
"don't know how to byteswap this array type"); "don't know how to byteswap this array type");
return NULL; return NULL;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -1349,8 +1345,7 @@ array_array_reverse_impl(arrayobject *self)
} }
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -1453,8 +1448,7 @@ array_array_tofile(arrayobject *self, PyObject *f)
} }
done: done:
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -1491,8 +1485,7 @@ array_array_fromlist(arrayobject *self, PyObject *list)
} }
} }
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -1557,8 +1550,7 @@ frombytes(arrayobject *self, Py_buffer *buffer)
buffer->buf, n * itemsize); buffer->buf, n * itemsize);
} }
PyBuffer_Release(buffer); PyBuffer_Release(buffer);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]

View File

@ -521,12 +521,10 @@ static PyObject*
faulthandler_disable_py(PyObject *self) faulthandler_disable_py(PyObject *self)
{ {
if (!fatal_error.enabled) { if (!fatal_error.enabled) {
Py_INCREF(Py_False); Py_RETURN_FALSE;
return Py_False;
} }
faulthandler_disable(); faulthandler_disable();
Py_INCREF(Py_True); Py_RETURN_TRUE;
return Py_True;
} }
static PyObject* static PyObject*

View File

@ -102,8 +102,7 @@ static PyObject *turnon_sigfpe(PyObject *self,PyObject *args)
/* Do any architecture-specific one-time only initialization here. */ /* Do any architecture-specific one-time only initialization here. */
fpe_reset(sigfpe_handler); fpe_reset(sigfpe_handler);
Py_INCREF (Py_None); Py_RETURN_NONE;
return Py_None;
} }
static void fpe_reset(Sigfunc *handler) static void fpe_reset(Sigfunc *handler)
@ -233,8 +232,7 @@ static PyObject *turnoff_sigfpe(PyObject *self,PyObject *args)
#else #else
fputs("Operation not implemented\n", stderr); fputs("Operation not implemented\n", stderr);
#endif #endif
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static void sigfpe_handler(int signo) static void sigfpe_handler(int signo)

View File

@ -95,8 +95,7 @@ static PyObject *test(PyObject *self,PyObject *args)
r = nest2(2, 2.0); r = nest2(2, 2.0);
printerr(r); printerr(r);
Py_INCREF (Py_None); Py_RETURN_NONE;
return Py_None;
} }
static void printerr(double r) static void printerr(double r)

View File

@ -1164,8 +1164,7 @@ static PyObject *
gc_enable(PyObject *self, PyObject *noargs) gc_enable(PyObject *self, PyObject *noargs)
{ {
enabled = 1; enabled = 1;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(gc_disable__doc__, PyDoc_STRVAR(gc_disable__doc__,
@ -1177,8 +1176,7 @@ static PyObject *
gc_disable(PyObject *self, PyObject *noargs) gc_disable(PyObject *self, PyObject *noargs)
{ {
enabled = 0; enabled = 0;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(gc_isenabled__doc__, PyDoc_STRVAR(gc_isenabled__doc__,
@ -1246,8 +1244,7 @@ gc_set_debug(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i:set_debug", &debug)) if (!PyArg_ParseTuple(args, "i:set_debug", &debug))
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(gc_get_debug__doc__, PyDoc_STRVAR(gc_get_debug__doc__,
@ -1281,8 +1278,7 @@ gc_set_thresh(PyObject *self, PyObject *args)
generations[i].threshold = generations[2].threshold; generations[i].threshold = generations[2].threshold;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(gc_get_thresh__doc__, PyDoc_STRVAR(gc_get_thresh__doc__,

View File

@ -416,8 +416,7 @@ MD5Type_update(MD5object *self, PyObject *obj)
md5_process(&self->hash_state, buf.buf, buf.len); md5_process(&self->hash_state, buf.buf, buf.len);
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyMethodDef MD5_methods[] = { static PyMethodDef MD5_methods[] = {

View File

@ -181,8 +181,7 @@ mmap_close_method(mmap_object *self, PyObject *unused)
} }
#endif #endif
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#ifdef MS_WINDOWS #ifdef MS_WINDOWS
@ -415,8 +414,7 @@ mmap_write_byte_method(mmap_object *self,
if (self->pos < self->size) { if (self->pos < self->size) {
self->data[self->pos++] = value; self->data[self->pos++] = value;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
else { else {
PyErr_SetString(PyExc_ValueError, "write byte out of range"); PyErr_SetString(PyExc_ValueError, "write byte out of range");
@ -524,8 +522,7 @@ mmap_resize_method(mmap_object *self,
new_size); new_size);
if (self->data != NULL) { if (self->data != NULL) {
self->size = new_size; self->size = new_size;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} else { } else {
dwErrCode = GetLastError(); dwErrCode = GetLastError();
CloseHandle(self->map_handle); CloseHandle(self->map_handle);
@ -567,8 +564,7 @@ mmap_resize_method(mmap_object *self,
} }
self->data = newmap; self->data = newmap;
self->size = new_size; self->size = new_size;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
#endif /* HAVE_MREMAP */ #endif /* HAVE_MREMAP */
#endif /* UNIX */ #endif /* UNIX */
} }
@ -644,8 +640,7 @@ mmap_seek_method(mmap_object *self, PyObject *args)
if (where > self->size || where < 0) if (where > self->size || where < 0)
goto onoutofrange; goto onoutofrange;
self->pos = where; self->pos = where;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
onoutofrange: onoutofrange:
@ -670,8 +665,7 @@ mmap_move_method(mmap_object *self, PyObject *args)
memmove(&self->data[dest], &self->data[src], cnt); memmove(&self->data[dest], &self->data[src], cnt);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
bounds: bounds:
PyErr_SetString(PyExc_ValueError, PyErr_SetString(PyExc_ValueError,

View File

@ -307,8 +307,7 @@ _do_ioctl_0(int fd, PyObject *args, char *fname, int cmd)
if (rv == -1) if (rv == -1)
return PyErr_SetFromErrno(PyExc_IOError); return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
@ -326,8 +325,7 @@ oss_nonblock(oss_audio_t *self, PyObject *unused)
mode once we're in non-blocking mode! */ mode once we're in non-blocking mode! */
if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1) if (ioctl(self->fd, SNDCTL_DSP_NONBLOCK, NULL) == -1)
return PyErr_SetFromErrno(PyExc_IOError); return PyErr_SetFromErrno(PyExc_IOError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -514,8 +512,7 @@ oss_writeall(oss_audio_t *self, PyObject *args)
cp += rv; cp += rv;
} }
PyBuffer_Release(&data); PyBuffer_Release(&data);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -527,8 +524,7 @@ oss_close(oss_audio_t *self, PyObject *unused)
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
self->fd = -1; self->fd = -1;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -747,8 +743,7 @@ oss_mixer_close(oss_mixer_t *self, PyObject *unused)
close(self->fd); close(self->fd);
self->fd = -1; self->fd = -1;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -91,8 +91,7 @@ node2tuple(node *n, /* node to convert */
PyObject *result = NULL, *w; PyObject *result = NULL, *w;
if (n == NULL) { if (n == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if (ISNONTERMINAL(TYPE(n))) { if (ISNONTERMINAL(TYPE(n))) {

View File

@ -1871,8 +1871,7 @@ stat_float_times(PyObject* self, PyObject *args)
/* Return old value */ /* Return old value */
return PyBool_FromLong(_stat_float_times); return PyBool_FromLong(_stat_float_times);
_stat_float_times = newval; _stat_float_times = newval;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject *billion = NULL; static PyObject *billion = NULL;
@ -6194,8 +6193,7 @@ posix_initgroups(PyObject *self, PyObject *args)
if (res == -1) if (res == -1)
return PyErr_SetFromErrno(PyExc_OSError); return PyErr_SetFromErrno(PyExc_OSError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#endif /* HAVE_INITGROUPS */ #endif /* HAVE_INITGROUPS */
@ -6258,8 +6256,7 @@ os_setpgrp_impl(PyObject *module)
if (setpgrp() < 0) if (setpgrp() < 0)
#endif /* SETPGRP_HAVE_ARG */ #endif /* SETPGRP_HAVE_ARG */
return posix_error(); return posix_error();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#endif /* HAVE_SETPGRP */ #endif /* HAVE_SETPGRP */
@ -6585,8 +6582,7 @@ os_setreuid_impl(PyObject *module, uid_t ruid, uid_t euid)
if (setreuid(ruid, euid) < 0) { if (setreuid(ruid, euid) < 0) {
return posix_error(); return posix_error();
} else { } else {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
} }
#endif /* HAVE_SETREUID */ #endif /* HAVE_SETREUID */
@ -6681,8 +6677,7 @@ os_setgroups(PyObject *module, PyObject *groups)
if (setgroups(len, grouplist) < 0) if (setgroups(len, grouplist) < 0)
return posix_error(); return posix_error();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#endif /* HAVE_SETGROUPS */ #endif /* HAVE_SETGROUPS */

View File

@ -161,8 +161,7 @@ conv_string_to_unicode(const XML_Char *str)
and hence in UTF-8. */ and hence in UTF-8. */
/* UTF-8 from Expat, Unicode desired */ /* UTF-8 from Expat, Unicode desired */
if (str == NULL) { if (str == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyUnicode_DecodeUTF8(str, strlen(str), "strict"); 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. */ and hence in UTF-8. */
/* UTF-8 from Expat, Unicode desired */ /* UTF-8 from Expat, Unicode desired */
if (str == NULL) { if (str == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyUnicode_DecodeUTF8((const char *)str, len, "strict"); 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) { if (rc != XML_ERROR_NONE) {
return set_error(self, rc); return set_error(self, rc);
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#endif #endif
@ -1322,8 +1319,7 @@ xmlparse_getattro(xmlparseobject *self, PyObject *nameobj)
return get_pybool((long) self->specified_attributes); return get_pybool((long) self->specified_attributes);
if (_PyUnicode_EqualToASCIIString(nameobj, "intern")) { if (_PyUnicode_EqualToASCIIString(nameobj, "intern")) {
if (self->intern == NULL) { if (self->intern == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
else { else {
Py_INCREF(self->intern); Py_INCREF(self->intern);

View File

@ -431,8 +431,7 @@ poll_register(pollObject *self, PyObject *args)
self->ufd_uptodate = 0; self->ufd_uptodate = 0;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(poll_modify_doc, PyDoc_STRVAR(poll_modify_doc,
@ -479,8 +478,7 @@ poll_modify(pollObject *self, PyObject *args)
self->ufd_uptodate = 0; self->ufd_uptodate = 0;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
@ -513,8 +511,7 @@ poll_unregister(pollObject *self, PyObject *o)
Py_DECREF(key); Py_DECREF(key);
self->ufd_uptodate = 0; self->ufd_uptodate = 0;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(poll_poll_doc, PyDoc_STRVAR(poll_poll_doc,

View File

@ -393,8 +393,7 @@ SHA1Type_update(SHA1object *self, PyObject *obj)
sha1_process(&self->hash_state, buf.buf, buf.len); sha1_process(&self->hash_state, buf.buf, buf.len);
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyMethodDef SHA1_methods[] = { static PyMethodDef SHA1_methods[] = {

View File

@ -483,8 +483,7 @@ SHA256Type_update(SHAobject *self, PyObject *obj)
sha_update(self, buf.buf, buf.len); sha_update(self, buf.buf, buf.len);
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyMethodDef SHA_methods[] = { static PyMethodDef SHA_methods[] = {

View File

@ -548,8 +548,7 @@ SHA512Type_update(SHAobject *self, PyObject *obj)
sha512_update(self, buf.buf, buf.len); sha512_update(self, buf.buf, buf.len);
PyBuffer_Release(&buf); PyBuffer_Release(&buf);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
dump buffer dump buffer

View File

@ -1218,8 +1218,7 @@ makesockaddr(SOCKET_T sockfd, struct sockaddr *addr, size_t addrlen, int proto)
{ {
if (addrlen == 0) { if (addrlen == 0) {
/* No address -- may be recvfrom() from known socket */ /* No address -- may be recvfrom() from known socket */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
switch (addr->sa_family) { switch (addr->sa_family) {
@ -2540,8 +2539,7 @@ static PyObject *
sock_gettimeout(PySocketSockObject *s) sock_gettimeout(PySocketSockObject *s)
{ {
if (s->sock_timeout < 0) { if (s->sock_timeout < 0) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
else { else {
double seconds = _PyTime_AsSecondsDouble(s->sock_timeout); double seconds = _PyTime_AsSecondsDouble(s->sock_timeout);
@ -2701,8 +2699,7 @@ sock_bind(PySocketSockObject *s, PyObject *addro)
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (res < 0) if (res < 0)
return s->errorhandler(); return s->errorhandler();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(bind_doc, PyDoc_STRVAR(bind_doc,
@ -2738,8 +2735,7 @@ sock_close(PySocketSockObject *s)
return s->errorhandler(); return s->errorhandler();
} }
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(close_doc, PyDoc_STRVAR(close_doc,
@ -2996,8 +2992,7 @@ sock_listen(PySocketSockObject *s, PyObject *args)
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (res < 0) if (res < 0)
return s->errorhandler(); return s->errorhandler();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(listen_doc, PyDoc_STRVAR(listen_doc,
@ -4363,8 +4358,7 @@ sock_shutdown(PySocketSockObject *s, PyObject *arg)
Py_END_ALLOW_THREADS Py_END_ALLOW_THREADS
if (res < 0) if (res < 0)
return s->errorhandler(); return s->errorhandler();
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(shutdown_doc, PyDoc_STRVAR(shutdown_doc,
@ -6196,8 +6190,7 @@ static PyObject *
socket_getdefaulttimeout(PyObject *self) socket_getdefaulttimeout(PyObject *self)
{ {
if (defaulttimeout < 0) { if (defaulttimeout < 0) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
else { else {
double seconds = _PyTime_AsSecondsDouble(defaulttimeout); double seconds = _PyTime_AsSecondsDouble(defaulttimeout);
@ -6222,8 +6215,7 @@ socket_setdefaulttimeout(PyObject *self, PyObject *arg)
defaulttimeout = timeout; defaulttimeout = timeout;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(setdefaulttimeout_doc, PyDoc_STRVAR(setdefaulttimeout_doc,

View File

@ -147,8 +147,7 @@ syslog_openlog(PyObject * self, PyObject * args, PyObject *kwds)
openlog(ident, logopt, facility); openlog(ident, logopt, facility);
S_log_open = 1; S_log_open = 1;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
@ -200,8 +199,7 @@ syslog_closelog(PyObject *self, PyObject *unused)
Py_CLEAR(S_ident_o); Py_CLEAR(S_ident_o);
S_log_open = 0; S_log_open = 0;
} }
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -194,8 +194,7 @@ termios_tcsetattr(PyObject *self, PyObject *args)
if (tcsetattr(fd, when, &mode) == -1) if (tcsetattr(fd, when, &mode) == -1)
return PyErr_SetFromErrno(TermiosError); return PyErr_SetFromErrno(TermiosError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(termios_tcsendbreak__doc__, PyDoc_STRVAR(termios_tcsendbreak__doc__,
@ -216,8 +215,7 @@ termios_tcsendbreak(PyObject *self, PyObject *args)
if (tcsendbreak(fd, duration) == -1) if (tcsendbreak(fd, duration) == -1)
return PyErr_SetFromErrno(TermiosError); return PyErr_SetFromErrno(TermiosError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(termios_tcdrain__doc__, PyDoc_STRVAR(termios_tcdrain__doc__,
@ -236,8 +234,7 @@ termios_tcdrain(PyObject *self, PyObject *args)
if (tcdrain(fd) == -1) if (tcdrain(fd) == -1)
return PyErr_SetFromErrno(TermiosError); return PyErr_SetFromErrno(TermiosError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(termios_tcflush__doc__, PyDoc_STRVAR(termios_tcflush__doc__,
@ -259,8 +256,7 @@ termios_tcflush(PyObject *self, PyObject *args)
if (tcflush(fd, queue) == -1) if (tcflush(fd, queue) == -1)
return PyErr_SetFromErrno(TermiosError); return PyErr_SetFromErrno(TermiosError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(termios_tcflow__doc__, PyDoc_STRVAR(termios_tcflow__doc__,
@ -282,8 +278,7 @@ termios_tcflow(PyObject *self, PyObject *args)
if (tcflow(fd, action) == -1) if (tcflow(fd, action) == -1)
return PyErr_SetFromErrno(TermiosError); return PyErr_SetFromErrno(TermiosError);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyMethodDef termios_methods[] = static PyMethodDef termios_methods[] =

View File

@ -234,8 +234,7 @@ time_sleep(PyObject *self, PyObject *obj)
} }
if (pysleep(secs) != 0) if (pysleep(secs) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(sleep_doc, PyDoc_STRVAR(sleep_doc,
@ -879,8 +878,7 @@ time_tzset(PyObject *self, PyObject *unused)
if (PyErr_Occurred()) if (PyErr_Occurred())
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(tzset_doc, PyDoc_STRVAR(tzset_doc,

View File

@ -677,8 +677,7 @@ zipimporter_get_source(PyObject *obj, PyObject *args)
} }
/* we have the module, but no source */ /* we have the module, but no source */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(doc_find_module, 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", PySys_FormatStderr("# %R has bad magic\n",
pathname); pathname);
} }
Py_INCREF(Py_None); Py_RETURN_NONE; /* signal caller to try alternative */
return Py_None; /* signal caller to try alternative */
} }
if (mtime != 0 && !eq_mtime(get_uint32(buf + 4), mtime)) { 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", PySys_FormatStderr("# %R has bad mtime\n",
pathname); pathname);
} }
Py_INCREF(Py_None); Py_RETURN_NONE; /* signal caller to try alternative */
return Py_None; /* signal caller to try alternative */
} }
/* XXX the pyc's size field is ignored; timestamp collisions are probably /* XXX the pyc's size field is ignored; timestamp collisions are probably

View File

@ -419,8 +419,7 @@ static PyObject *
member_get_doc(PyMemberDescrObject *descr, void *closure) member_get_doc(PyMemberDescrObject *descr, void *closure)
{ {
if (descr->d_member->doc == NULL) { if (descr->d_member->doc == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyUnicode_FromString(descr->d_member->doc); return PyUnicode_FromString(descr->d_member->doc);
} }
@ -435,8 +434,7 @@ static PyObject *
getset_get_doc(PyGetSetDescrObject *descr, void *closure) getset_get_doc(PyGetSetDescrObject *descr, void *closure)
{ {
if (descr->d_getset->doc == NULL) { if (descr->d_getset->doc == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyUnicode_FromString(descr->d_getset->doc); return PyUnicode_FromString(descr->d_getset->doc);
} }

View File

@ -184,8 +184,7 @@ static PyObject *
BaseException_get_args(PyBaseExceptionObject *self) BaseException_get_args(PyBaseExceptionObject *self)
{ {
if (self->args == NULL) { if (self->args == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
Py_INCREF(self->args); Py_INCREF(self->args);
return self->args; return self->args;
@ -210,8 +209,7 @@ static PyObject *
BaseException_get_tb(PyBaseExceptionObject *self) BaseException_get_tb(PyBaseExceptionObject *self)
{ {
if (self->traceback == NULL) { if (self->traceback == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
Py_INCREF(self->traceback); Py_INCREF(self->traceback);
return self->traceback; return self->traceback;

View File

@ -456,8 +456,7 @@ static PyMethodDef stdprinter_methods[] = {
static PyObject * static PyObject *
get_closed(PyStdPrinter_Object *self, void *closure) get_closed(PyStdPrinter_Object *self, void *closure)
{ {
Py_INCREF(Py_False); Py_RETURN_FALSE;
return Py_False;
} }
static PyObject * static PyObject *

View File

@ -322,8 +322,7 @@ static PyObject *
func_get_defaults(PyFunctionObject *op) func_get_defaults(PyFunctionObject *op)
{ {
if (op->func_defaults == NULL) { if (op->func_defaults == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
Py_INCREF(op->func_defaults); Py_INCREF(op->func_defaults);
return op->func_defaults; return op->func_defaults;
@ -350,8 +349,7 @@ static PyObject *
func_get_kwdefaults(PyFunctionObject *op) func_get_kwdefaults(PyFunctionObject *op)
{ {
if (op->func_kwdefaults == NULL) { if (op->func_kwdefaults == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
Py_INCREF(op->func_kwdefaults); Py_INCREF(op->func_kwdefaults);
return op->func_kwdefaults; return op->func_kwdefaults;

View File

@ -402,8 +402,7 @@ gen_close(PyGenObject *gen, PyObject *args)
if (PyErr_ExceptionMatches(PyExc_StopIteration) if (PyErr_ExceptionMatches(PyExc_StopIteration)
|| PyErr_ExceptionMatches(PyExc_GeneratorExit)) { || PyErr_ExceptionMatches(PyExc_GeneratorExit)) {
PyErr_Clear(); /* ignore these errors */ PyErr_Clear(); /* ignore these errors */
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return NULL; return NULL;
} }

View File

@ -2284,12 +2284,10 @@ list_richcompare(PyObject *v, PyObject *w, int op)
/* We have an item that differs -- shortcuts for EQ/NE */ /* We have an item that differs -- shortcuts for EQ/NE */
if (op == Py_EQ) { if (op == Py_EQ) {
Py_INCREF(Py_False); Py_RETURN_FALSE;
return Py_False;
} }
if (op == Py_NE) { if (op == Py_NE) {
Py_INCREF(Py_True); Py_RETURN_TRUE;
return Py_True;
} }
/* Compare the final item again using the proper operator */ /* Compare the final item again using the proper operator */

View File

@ -631,12 +631,10 @@ tuplerichcompare(PyObject *v, PyObject *w, int op)
/* We have an item that differs -- shortcuts for EQ/NE */ /* We have an item that differs -- shortcuts for EQ/NE */
if (op == Py_EQ) { if (op == Py_EQ) {
Py_INCREF(Py_False); Py_RETURN_FALSE;
return Py_False;
} }
if (op == Py_NE) { if (op == Py_NE) {
Py_INCREF(Py_True); Py_RETURN_TRUE;
return Py_True;
} }
/* Compare the final item again using the proper operator */ /* Compare the final item again using the proper operator */

View File

@ -140,8 +140,7 @@ _PyType_GetDocFromInternalDoc(const char *name, const char *internal_doc)
const char *doc = _PyType_DocWithoutSignature(name, internal_doc); const char *doc = _PyType_DocWithoutSignature(name, internal_doc);
if (!doc || *doc == '\0') { if (!doc || *doc == '\0') {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyUnicode_FromString(doc); return PyUnicode_FromString(doc);
@ -158,8 +157,7 @@ _PyType_GetTextSignatureFromInternalDoc(const char *name, const char *internal_d
else else
end = NULL; end = NULL;
if (!end) { if (!end) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* back "end" up until it points just past the final ')' */ /* back "end" up until it points just past the final ')' */
@ -761,8 +759,7 @@ static PyObject *
type_dict(PyTypeObject *type, void *context) type_dict(PyTypeObject *type, void *context)
{ {
if (type->tp_dict == NULL) { if (type->tp_dict == NULL) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
return PyDictProxy_New(type->tp_dict); return PyDictProxy_New(type->tp_dict);
} }
@ -5330,8 +5327,7 @@ wrap_sq_setitem(PyObject *self, PyObject *args, void *wrapped)
res = (*func)(self, i, value); res = (*func)(self, i, value);
if (res == -1 && PyErr_Occurred()) if (res == -1 && PyErr_Occurred())
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -5351,8 +5347,7 @@ wrap_sq_delitem(PyObject *self, PyObject *args, void *wrapped)
res = (*func)(self, i, NULL); res = (*func)(self, i, NULL);
if (res == -1 && PyErr_Occurred()) if (res == -1 && PyErr_Occurred())
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* XXX objobjproc is a misnomer; should be objargpred */ /* 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); res = (*func)(self, key, value);
if (res == -1 && PyErr_Occurred()) if (res == -1 && PyErr_Occurred())
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -5402,8 +5396,7 @@ wrap_delitem(PyObject *self, PyObject *args, void *wrapped)
res = (*func)(self, key, NULL); res = (*func)(self, key, NULL);
if (res == -1 && PyErr_Occurred()) if (res == -1 && PyErr_Occurred())
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/* Helper to check for object.__setattr__ or __delattr__ applied to a type. /* 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); res = (*func)(self, name, value);
if (res < 0) if (res < 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -5459,8 +5451,7 @@ wrap_delattr(PyObject *self, PyObject *args, void *wrapped)
res = (*func)(self, name, NULL); res = (*func)(self, name, NULL);
if (res < 0) if (res < 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -5571,8 +5562,7 @@ wrap_descr_set(PyObject *self, PyObject *args, void *wrapped)
ret = (*func)(self, obj, value); ret = (*func)(self, obj, value);
if (ret < 0) if (ret < 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -5588,8 +5578,7 @@ wrap_descr_delete(PyObject *self, PyObject *args, void *wrapped)
ret = (*func)(self, obj, NULL); ret = (*func)(self, obj, NULL);
if (ret < 0) if (ret < 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -5599,8 +5588,7 @@ wrap_init(PyObject *self, PyObject *args, void *wrapped, PyObject *kwds)
if (func(self, args, kwds) < 0) if (func(self, args, kwds) < 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *

View File

@ -8254,9 +8254,7 @@ charmapencode_lookup(Py_UCS4 c, PyObject *mapping)
if (PyErr_ExceptionMatches(PyExc_LookupError)) { if (PyErr_ExceptionMatches(PyExc_LookupError)) {
/* No mapping found means: mapping is undefined. */ /* No mapping found means: mapping is undefined. */
PyErr_Clear(); PyErr_Clear();
x = Py_None; Py_RETURN_NONE;
Py_INCREF(x);
return x;
} else } else
return NULL; return NULL;
} }

View File

@ -262,8 +262,7 @@ static PyObject* fcicreate(PyObject* obj, PyObject* args)
if (!FCIDestroy(hfci)) if (!FCIDestroy(hfci))
goto err; goto err;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
err: err:
if(erf.fError) if(erf.fError)
PyErr_Format(PyExc_ValueError, "FCI error %d", erf.erfOper); /* XXX better error type */ 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); MsiCloseHandle(msidb->h);
msidb->h = 0; msidb->h = 0;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -401,8 +399,7 @@ record_cleardata(msiobj* record, PyObject *args)
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -418,8 +415,7 @@ record_setstring(msiobj* record, PyObject *args)
if ((status = MsiRecordSetStringW(record->h, field, data)) != ERROR_SUCCESS) if ((status = MsiRecordSetStringW(record->h, field, data)) != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -435,8 +431,7 @@ record_setstream(msiobj* record, PyObject *args)
if ((status = MsiRecordSetStreamW(record->h, field, data)) != ERROR_SUCCESS) if ((status = MsiRecordSetStreamW(record->h, field, data)) != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -452,8 +447,7 @@ record_setinteger(msiobj* record, PyObject *args)
if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS) if ((status = MsiRecordSetInteger(record->h, field, data)) != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
@ -617,8 +611,7 @@ summary_setproperty(msiobj* si, PyObject *args)
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
@ -630,8 +623,7 @@ summary_persist(msiobj* si, PyObject *args)
status = MsiSummaryInfoPersist(si->h); status = MsiSummaryInfoPersist(si->h);
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyMethodDef summary_methods[] = { static PyMethodDef summary_methods[] = {
@ -714,8 +706,7 @@ view_execute(msiobj *view, PyObject*args)
if (status != ERROR_SUCCESS) if (status != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -764,8 +755,7 @@ view_modify(msiobj *view, PyObject *args)
if ((status = MsiViewModify(view->h, kind, ((msiobj*)data)->h)) != ERROR_SUCCESS) if ((status = MsiViewModify(view->h, kind, ((msiobj*)data)->h)) != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*
@ -776,8 +766,7 @@ view_close(msiobj *view, PyObject*args)
if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS) if ((status = MsiViewClose(view->h)) != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyMethodDef view_methods[] = { static PyMethodDef view_methods[] = {
@ -872,8 +861,7 @@ msidb_commit(msiobj *msidb, PyObject *args)
if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS) if ((status = MsiDatabaseCommit(msidb->h)) != ERROR_SUCCESS)
return msierror(status); return msierror(status);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject* static PyObject*

View File

@ -2583,8 +2583,7 @@ ast2obj_mod(void* _o)
mod_ty o = (mod_ty)_o; mod_ty o = (mod_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
switch (o->kind) { switch (o->kind) {
@ -2638,8 +2637,7 @@ ast2obj_stmt(void* _o)
stmt_ty o = (stmt_ty)_o; stmt_ty o = (stmt_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
switch (o->kind) { switch (o->kind) {
@ -3063,8 +3061,7 @@ ast2obj_expr(void* _o)
expr_ty o = (expr_ty)_o; expr_ty o = (expr_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
switch (o->kind) { switch (o->kind) {
@ -3526,8 +3523,7 @@ ast2obj_slice(void* _o)
slice_ty o = (slice_ty)_o; slice_ty o = (slice_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
switch (o->kind) { switch (o->kind) {
@ -3705,8 +3701,7 @@ ast2obj_comprehension(void* _o)
comprehension_ty o = (comprehension_ty)_o; comprehension_ty o = (comprehension_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyType_GenericNew(comprehension_type, NULL, NULL); result = PyType_GenericNew(comprehension_type, NULL, NULL);
@ -3744,8 +3739,7 @@ ast2obj_excepthandler(void* _o)
excepthandler_ty o = (excepthandler_ty)_o; excepthandler_ty o = (excepthandler_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
switch (o->kind) { switch (o->kind) {
@ -3792,8 +3786,7 @@ ast2obj_arguments(void* _o)
arguments_ty o = (arguments_ty)_o; arguments_ty o = (arguments_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyType_GenericNew(arguments_type, NULL, NULL); result = PyType_GenericNew(arguments_type, NULL, NULL);
@ -3841,8 +3834,7 @@ ast2obj_arg(void* _o)
arg_ty o = (arg_ty)_o; arg_ty o = (arg_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyType_GenericNew(arg_type, NULL, NULL); result = PyType_GenericNew(arg_type, NULL, NULL);
@ -3880,8 +3872,7 @@ ast2obj_keyword(void* _o)
keyword_ty o = (keyword_ty)_o; keyword_ty o = (keyword_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyType_GenericNew(keyword_type, NULL, NULL); result = PyType_GenericNew(keyword_type, NULL, NULL);
@ -3909,8 +3900,7 @@ ast2obj_alias(void* _o)
alias_ty o = (alias_ty)_o; alias_ty o = (alias_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyType_GenericNew(alias_type, NULL, NULL); result = PyType_GenericNew(alias_type, NULL, NULL);
@ -3938,8 +3928,7 @@ ast2obj_withitem(void* _o)
withitem_ty o = (withitem_ty)_o; withitem_ty o = (withitem_ty)_o;
PyObject *result = NULL, *value = NULL; PyObject *result = NULL, *value = NULL;
if (!o) { if (!o) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
result = PyType_GenericNew(withitem_type, NULL, NULL); result = PyType_GenericNew(withitem_type, NULL, NULL);

View File

@ -1369,8 +1369,7 @@ builtin_setattr_impl(PyObject *module, PyObject *obj, PyObject *name,
{ {
if (PyObject_SetAttr(obj, name, value) != 0) if (PyObject_SetAttr(obj, name, value) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
@ -1392,8 +1391,7 @@ builtin_delattr_impl(PyObject *module, PyObject *obj, PyObject *name)
{ {
if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0) if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }

View File

@ -260,8 +260,7 @@ _imp_acquire_lock_impl(PyObject *module)
#ifdef WITH_THREAD #ifdef WITH_THREAD
_PyImport_AcquireLock(); _PyImport_AcquireLock();
#endif #endif
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
/*[clinic input] /*[clinic input]
@ -283,8 +282,7 @@ _imp_release_lock_impl(PyObject *module)
return NULL; return NULL;
} }
#endif #endif
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
void void
@ -1853,8 +1851,7 @@ _imp_init_frozen_impl(PyObject *module, PyObject *name)
if (ret < 0) if (ret < 0)
return NULL; return NULL;
if (ret == 0) { if (ret == 0) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
m = PyImport_AddModuleObject(name); m = PyImport_AddModuleObject(name);
Py_XINCREF(m); Py_XINCREF(m);

View File

@ -514,8 +514,7 @@ va_build_value(const char *format, va_list va, int flags)
if (n < 0) if (n < 0)
return NULL; return NULL;
if (n == 0) { if (n == 0) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
va_copy(lva, va); va_copy(lva, va);
if (n == 1) { if (n == 1) {

View File

@ -179,8 +179,7 @@ sys_displayhook(PyObject *self, PyObject *o)
/* After printing, also assign to '_' */ /* After printing, also assign to '_' */
/* Before, set '_' to None to avoid recursion */ /* Before, set '_' to None to avoid recursion */
if (o == Py_None) { if (o == Py_None) {
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0) if (_PyObject_SetAttrId(builtins, &PyId__, Py_None) != 0)
return NULL; return NULL;
@ -211,8 +210,7 @@ sys_displayhook(PyObject *self, PyObject *o)
return NULL; return NULL;
if (_PyObject_SetAttrId(builtins, &PyId__, o) != 0) if (_PyObject_SetAttrId(builtins, &PyId__, o) != 0)
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(displayhook_doc, PyDoc_STRVAR(displayhook_doc,
@ -228,8 +226,7 @@ sys_excepthook(PyObject* self, PyObject* args)
if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb)) if (!PyArg_UnpackTuple(args, "excepthook", 3, 3, &exc, &value, &tb))
return NULL; return NULL;
PyErr_Display(exc, value, tb); PyErr_Display(exc, value, tb);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(excepthook_doc, PyDoc_STRVAR(excepthook_doc,
@ -461,8 +458,7 @@ sys_settrace(PyObject *self, PyObject *args)
PyEval_SetTrace(NULL, NULL); PyEval_SetTrace(NULL, NULL);
else else
PyEval_SetTrace(trace_trampoline, args); PyEval_SetTrace(trace_trampoline, args);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(settrace_doc, PyDoc_STRVAR(settrace_doc,
@ -500,8 +496,7 @@ sys_setprofile(PyObject *self, PyObject *args)
PyEval_SetProfile(NULL, NULL); PyEval_SetProfile(NULL, NULL);
else else
PyEval_SetProfile(profile_trampoline, args); PyEval_SetProfile(profile_trampoline, args);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(setprofile_doc, PyDoc_STRVAR(setprofile_doc,
@ -542,8 +537,7 @@ sys_setcheckinterval(PyObject *self, PyObject *args)
return NULL; return NULL;
if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval)) if (!PyArg_ParseTuple(args, "i:setcheckinterval", &_check_interval))
return NULL; return NULL;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(setcheckinterval_doc, PyDoc_STRVAR(setcheckinterval_doc,
@ -581,8 +575,7 @@ sys_setswitchinterval(PyObject *self, PyObject *args)
return NULL; return NULL;
} }
_PyEval_SetSwitchInterval((unsigned long) (1e6 * d)); _PyEval_SetSwitchInterval((unsigned long) (1e6 * d));
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(setswitchinterval_doc, PyDoc_STRVAR(setswitchinterval_doc,
@ -644,8 +637,7 @@ sys_setrecursionlimit(PyObject *self, PyObject *args)
} }
Py_SetRecursionLimit(new_limit); Py_SetRecursionLimit(new_limit);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
static PyObject * static PyObject *
@ -1032,8 +1024,7 @@ sys_setdlopenflags(PyObject *self, PyObject *args)
if (!tstate) if (!tstate)
return NULL; return NULL;
tstate->interp->dlopenflags = new_val; tstate->interp->dlopenflags = new_val;
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
PyDoc_STRVAR(setdlopenflags_doc, PyDoc_STRVAR(setdlopenflags_doc,
@ -1074,8 +1065,7 @@ sys_mdebug(PyObject *self, PyObject *args)
if (!PyArg_ParseTuple(args, "i:mdebug", &flag)) if (!PyArg_ParseTuple(args, "i:mdebug", &flag))
return NULL; return NULL;
mallopt(M_DEBUG, flag); mallopt(M_DEBUG, flag);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
} }
#endif /* USE_MALLOPT */ #endif /* USE_MALLOPT */