Issue #28999: Use Py_RETURN_NONE, Py_RETURN_TRUE and Py_RETURN_FALSE wherever
possible.  Patch is writen with Coccinelle.
diff --git a/Python/Python-ast.c b/Python/Python-ast.c
index e0607ba..a049641 100644
--- a/Python/Python-ast.c
+++ b/Python/Python-ast.c
@@ -2583,8 +2583,7 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     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 @@
     withitem_ty o = (withitem_ty)_o;
     PyObject *result = NULL, *value = NULL;
     if (!o) {
-        Py_INCREF(Py_None);
-        return Py_None;
+        Py_RETURN_NONE;
     }
 
     result = PyType_GenericNew(withitem_type, NULL, NULL);
diff --git a/Python/bltinmodule.c b/Python/bltinmodule.c
index 3473cc3..2204344 100644
--- a/Python/bltinmodule.c
+++ b/Python/bltinmodule.c
@@ -1369,8 +1369,7 @@
 {
     if (PyObject_SetAttr(obj, name, value) != 0)
         return NULL;
-    Py_INCREF(Py_None);
-    return Py_None;
+    Py_RETURN_NONE;
 }
 
 
@@ -1392,8 +1391,7 @@
 {
     if (PyObject_SetAttr(obj, name, (PyObject *)NULL) != 0)
         return NULL;
-    Py_INCREF(Py_None);
-    return Py_None;
+    Py_RETURN_NONE;
 }
 
 
diff --git a/Python/import.c b/Python/import.c
index aef1800..38976f6 100644
--- a/Python/import.c
+++ b/Python/import.c
@@ -260,8 +260,7 @@
 #ifdef WITH_THREAD
     _PyImport_AcquireLock();
 #endif
-    Py_INCREF(Py_None);
-    return Py_None;
+    Py_RETURN_NONE;
 }
 
 /*[clinic input]
@@ -283,8 +282,7 @@
         return NULL;
     }
 #endif
-    Py_INCREF(Py_None);
-    return Py_None;
+    Py_RETURN_NONE;
 }
 
 void
@@ -1853,8 +1851,7 @@
     if (ret < 0)
         return NULL;
     if (ret == 0) {
-        Py_INCREF(Py_None);
-        return Py_None;
+        Py_RETURN_NONE;
     }
     m = PyImport_AddModuleObject(name);
     Py_XINCREF(m);
diff --git a/Python/modsupport.c b/Python/modsupport.c
index 01b5dc9..e9e025b 100644
--- a/Python/modsupport.c
+++ b/Python/modsupport.c
@@ -514,8 +514,7 @@
     if (n < 0)
         return NULL;
     if (n == 0) {
-        Py_INCREF(Py_None);
-        return Py_None;
+        Py_RETURN_NONE;
     }
     va_copy(lva, va);
     if (n == 1) {
diff --git a/Python/sysmodule.c b/Python/sysmodule.c
index 9c4d9e6..81520ea 100644
--- a/Python/sysmodule.c
+++ b/Python/sysmodule.c
@@ -179,8 +179,7 @@
     /* 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 @@
         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 @@
     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 @@
         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 @@
         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 @@
         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 @@
         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 @@
     }
 
     Py_SetRecursionLimit(new_limit);
-    Py_INCREF(Py_None);
-    return Py_None;
+    Py_RETURN_NONE;
 }
 
 static PyObject *
@@ -1032,8 +1024,7 @@
     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 @@
     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 */