Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever

possible but Coccinelle couldn't find opportunity.
This commit is contained in:
Serhiy Storchaka 2017-01-23 10:23:58 +02:00
parent 228b12edcc
commit d1302c0154
5 changed files with 10 additions and 19 deletions

View File

@ -154,19 +154,16 @@ static PyObject *PyCurses_ ## X (PyObject *self) \
{ \ { \
PyCursesInitialised \ PyCursesInitialised \
if (X () == FALSE) { \ if (X () == FALSE) { \
Py_INCREF(Py_False); \ Py_RETURN_FALSE; \
return Py_False; \
} \ } \
Py_INCREF(Py_True); \ Py_RETURN_TRUE; }
return Py_True; }
#define NoArgNoReturnVoidFunction(X) \ #define NoArgNoReturnVoidFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \ static PyObject *PyCurses_ ## X (PyObject *self) \
{ \ { \
PyCursesInitialised \ PyCursesInitialised \
X(); \ X(); \
Py_INCREF(Py_None); \ Py_RETURN_NONE; }
return Py_None; }
#ifdef __cplusplus #ifdef __cplusplus
} }

View File

@ -498,7 +498,7 @@ get_ulonglong(PyObject *v, unsigned long long *p)
#ifdef _CTYPES_DEBUG_KEEP #ifdef _CTYPES_DEBUG_KEEP
#define _RET(x) Py_INCREF(x); return x #define _RET(x) Py_INCREF(x); return x
#else #else
#define _RET(X) Py_INCREF(Py_None); return Py_None #define _RET(X) Py_RETURN_NONE
#endif #endif
/***************************************************************** /*****************************************************************

View File

@ -1108,17 +1108,15 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
case 'n': case 'n':
/* null */ /* null */
if ((idx + 3 < length) && PyUnicode_READ(kind, str, idx + 1) == 'u' && PyUnicode_READ(kind, str, idx + 2) == 'l' && PyUnicode_READ(kind, str, idx + 3) == 'l') { if ((idx + 3 < length) && PyUnicode_READ(kind, str, idx + 1) == 'u' && PyUnicode_READ(kind, str, idx + 2) == 'l' && PyUnicode_READ(kind, str, idx + 3) == 'l') {
Py_INCREF(Py_None);
*next_idx_ptr = idx + 4; *next_idx_ptr = idx + 4;
return Py_None; Py_RETURN_NONE;
} }
break; break;
case 't': case 't':
/* true */ /* true */
if ((idx + 3 < length) && PyUnicode_READ(kind, str, idx + 1) == 'r' && PyUnicode_READ(kind, str, idx + 2) == 'u' && PyUnicode_READ(kind, str, idx + 3) == 'e') { if ((idx + 3 < length) && PyUnicode_READ(kind, str, idx + 1) == 'r' && PyUnicode_READ(kind, str, idx + 2) == 'u' && PyUnicode_READ(kind, str, idx + 3) == 'e') {
Py_INCREF(Py_True);
*next_idx_ptr = idx + 4; *next_idx_ptr = idx + 4;
return Py_True; Py_RETURN_TRUE;
} }
break; break;
case 'f': case 'f':
@ -1127,9 +1125,8 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
PyUnicode_READ(kind, str, idx + 2) == 'l' && PyUnicode_READ(kind, str, idx + 2) == 'l' &&
PyUnicode_READ(kind, str, idx + 3) == 's' && PyUnicode_READ(kind, str, idx + 3) == 's' &&
PyUnicode_READ(kind, str, idx + 4) == 'e') { PyUnicode_READ(kind, str, idx + 4) == 'e') {
Py_INCREF(Py_False);
*next_idx_ptr = idx + 5; *next_idx_ptr = idx + 5;
return Py_False; Py_RETURN_FALSE;
} }
break; break;
case 'N': case 'N':

View File

@ -117,8 +117,7 @@ test_sizeof_c_types(PyObject *self)
CHECK_SIZEOF(intptr_t, sizeof(void *)); CHECK_SIZEOF(intptr_t, sizeof(void *));
CHECK_SIGNNESS(intptr_t, 1); CHECK_SIGNNESS(intptr_t, 1);
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
#undef IS_SIGNED #undef IS_SIGNED
#undef CHECK_SIGNESS #undef CHECK_SIGNESS

View File

@ -60,10 +60,8 @@ SubString_init(SubString *str, PyObject *s, Py_ssize_t start, Py_ssize_t end)
Py_LOCAL_INLINE(PyObject *) Py_LOCAL_INLINE(PyObject *)
SubString_new_object(SubString *str) SubString_new_object(SubString *str)
{ {
if (str->str == NULL) { if (str->str == NULL)
Py_INCREF(Py_None); Py_RETURN_NONE;
return Py_None;
}
return PyUnicode_Substring(str->str, str->start, str->end); return PyUnicode_Substring(str->str, str->start, str->end);
} }