summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorSerhiy Storchaka <storchaka@gmail.com>2017-01-23 10:23:58 +0200
committerSerhiy Storchaka <storchaka@gmail.com>2017-01-23 10:23:58 +0200
commit1bd620bca594ba9193c63e79e7836765d23047cc (patch)
treedecee76f583199d033187e74c44277f7f79e4895
parentbfeec6d871e3db2e0ddfdef01387913bc19cadd4 (diff)
downloadcpython-1bd620bca594ba9193c63e79e7836765d23047cc.tar.gz
Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
possible but Coccinelle couldn't find opportunity.
-rw-r--r--Include/py_curses.h9
-rw-r--r--Modules/_ctypes/cfield.c2
-rw-r--r--Modules/_json.c9
-rw-r--r--Modules/_testcapimodule.c3
-rw-r--r--Objects/stringlib/unicode_format.h6
5 files changed, 10 insertions, 19 deletions
diff --git a/Include/py_curses.h b/Include/py_curses.h
index 3c21697073..336c95d360 100644
--- a/Include/py_curses.h
+++ b/Include/py_curses.h
@@ -154,19 +154,16 @@ static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
if (X () == FALSE) { \
- Py_INCREF(Py_False); \
- return Py_False; \
+ Py_RETURN_FALSE; \
} \
- Py_INCREF(Py_True); \
- return Py_True; }
+ Py_RETURN_TRUE; }
#define NoArgNoReturnVoidFunction(X) \
static PyObject *PyCurses_ ## X (PyObject *self) \
{ \
PyCursesInitialised \
X(); \
- Py_INCREF(Py_None); \
- return Py_None; }
+ Py_RETURN_NONE; }
#ifdef __cplusplus
}
diff --git a/Modules/_ctypes/cfield.c b/Modules/_ctypes/cfield.c
index ec30b8cc44..bb9b115bd2 100644
--- a/Modules/_ctypes/cfield.c
+++ b/Modules/_ctypes/cfield.c
@@ -498,7 +498,7 @@ get_ulonglong(PyObject *v, unsigned long long *p)
#ifdef _CTYPES_DEBUG_KEEP
#define _RET(x) Py_INCREF(x); return x
#else
-#define _RET(X) Py_INCREF(Py_None); return Py_None
+#define _RET(X) Py_RETURN_NONE
#endif
/*****************************************************************
diff --git a/Modules/_json.c b/Modules/_json.c
index 941f36343d..f4000f83a5 100644
--- a/Modules/_json.c
+++ b/Modules/_json.c
@@ -1108,17 +1108,15 @@ scan_once_unicode(PyScannerObject *s, PyObject *pystr, Py_ssize_t idx, Py_ssize_
case 'n':
/* 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') {
- Py_INCREF(Py_None);
*next_idx_ptr = idx + 4;
- return Py_None;
+ Py_RETURN_NONE;
}
break;
case 't':
/* 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') {
- Py_INCREF(Py_True);
*next_idx_ptr = idx + 4;
- return Py_True;
+ Py_RETURN_TRUE;
}
break;
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 + 3) == 's' &&
PyUnicode_READ(kind, str, idx + 4) == 'e') {
- Py_INCREF(Py_False);
*next_idx_ptr = idx + 5;
- return Py_False;
+ Py_RETURN_FALSE;
}
break;
case 'N':
diff --git a/Modules/_testcapimodule.c b/Modules/_testcapimodule.c
index 6d6b72a1c6..03a4acbc79 100644
--- a/Modules/_testcapimodule.c
+++ b/Modules/_testcapimodule.c
@@ -117,8 +117,7 @@ test_sizeof_c_types(PyObject *self)
CHECK_SIZEOF(intptr_t, sizeof(void *));
CHECK_SIGNNESS(intptr_t, 1);
- Py_INCREF(Py_None);
- return Py_None;
+ Py_RETURN_NONE;
#undef IS_SIGNED
#undef CHECK_SIGNESS
diff --git a/Objects/stringlib/unicode_format.h b/Objects/stringlib/unicode_format.h
index 14fa28ea54..7ac0d75166 100644
--- a/Objects/stringlib/unicode_format.h
+++ b/Objects/stringlib/unicode_format.h
@@ -60,10 +60,8 @@ SubString_init(SubString *str, PyObject *s, Py_ssize_t start, Py_ssize_t end)
Py_LOCAL_INLINE(PyObject *)
SubString_new_object(SubString *str)
{
- if (str->str == NULL) {
- Py_INCREF(Py_None);
- return Py_None;
- }
+ if (str->str == NULL)
+ Py_RETURN_NONE;
return PyUnicode_Substring(str->str, str->start, str->end);
}