]> granicus.if.org Git - python/commitdiff
Parser/asdl_c.py: use Py_CLEAR()
authorVictor Stinner <victor.stinner@gmail.com>
Fri, 26 Jul 2013 22:03:47 +0000 (00:03 +0200)
committerVictor Stinner <victor.stinner@gmail.com>
Fri, 26 Jul 2013 22:03:47 +0000 (00:03 +0200)
Parser/asdl_c.py
Python/Python-ast.c

index 8f0da4adc1a835476786de05565ddae482e4caf5..25682229cc5c90a3e55cd87b649cbe92a11442dd 100755 (executable)
@@ -526,8 +526,7 @@ class Obj2ModVisitor(PickleVisitor):
                       (field.type, field.name), depth+1)
             self.emit("if (res != 0) goto failed;", depth+1)
 
-        self.emit("Py_XDECREF(tmp);", depth+1)
-        self.emit("tmp = NULL;", depth+1)
+        self.emit("Py_CLEAR(tmp);", depth+1)
         self.emit("} else {", depth)
         if not field.opt:
             message = "required field \\\"%s\\\" missing from %s" % (field.name, name)
index e7c8f6d1176e5a556a240468b5079e6aa52b52d9..d78657ce0755b2f89fd37565e3906e6371c50bb9 100644 (file)
@@ -3553,8 +3553,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Module");
             return 1;
@@ -3589,8 +3588,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Interactive");
             return 1;
@@ -3612,8 +3610,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &body, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Expression");
             return 1;
@@ -3648,8 +3645,7 @@ obj2ast_mod(PyObject* obj, mod_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Suite");
             return 1;
@@ -3684,8 +3680,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_int(tmp, &lineno, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from stmt");
         return 1;
@@ -3696,8 +3691,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_int(tmp, &col_offset, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from stmt");
         return 1;
@@ -3719,8 +3713,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_identifier(tmp, &name, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from FunctionDef");
             return 1;
@@ -3731,8 +3724,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_arguments(tmp, &args, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from FunctionDef");
             return 1;
@@ -3756,8 +3748,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from FunctionDef");
             return 1;
@@ -3781,8 +3772,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(decorator_list, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from FunctionDef");
             return 1;
@@ -3793,8 +3783,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &returns, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             returns = NULL;
         }
@@ -3822,8 +3811,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_identifier(tmp, &name, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from ClassDef");
             return 1;
@@ -3847,8 +3835,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(bases, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"bases\" missing from ClassDef");
             return 1;
@@ -3872,8 +3859,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(keywords, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from ClassDef");
             return 1;
@@ -3884,8 +3870,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &starargs, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             starargs = NULL;
         }
@@ -3895,8 +3880,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &kwargs, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             kwargs = NULL;
         }
@@ -3919,8 +3903,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ClassDef");
             return 1;
@@ -3944,8 +3927,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(decorator_list, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"decorator_list\" missing from ClassDef");
             return 1;
@@ -3968,8 +3950,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             value = NULL;
         }
@@ -4003,8 +3984,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(targets, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Delete");
             return 1;
@@ -4040,8 +4020,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(targets, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"targets\" missing from Assign");
             return 1;
@@ -4052,8 +4031,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Assign");
             return 1;
@@ -4077,8 +4055,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &target, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from AugAssign");
             return 1;
@@ -4089,8 +4066,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_operator(tmp, &op, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from AugAssign");
             return 1;
@@ -4101,8 +4077,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from AugAssign");
             return 1;
@@ -4127,8 +4102,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &target, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from For");
             return 1;
@@ -4139,8 +4113,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &iter, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from For");
             return 1;
@@ -4164,8 +4137,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from For");
             return 1;
@@ -4189,8 +4161,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(orelse, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from For");
             return 1;
@@ -4214,8 +4185,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &test, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from While");
             return 1;
@@ -4239,8 +4209,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from While");
             return 1;
@@ -4264,8 +4233,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(orelse, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from While");
             return 1;
@@ -4289,8 +4257,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &test, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from If");
             return 1;
@@ -4314,8 +4281,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from If");
             return 1;
@@ -4339,8 +4305,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(orelse, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from If");
             return 1;
@@ -4376,8 +4341,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(items, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"items\" missing from With");
             return 1;
@@ -4401,8 +4365,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from With");
             return 1;
@@ -4425,8 +4388,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &exc, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             exc = NULL;
         }
@@ -4436,8 +4398,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &cause, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             cause = NULL;
         }
@@ -4474,8 +4435,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Try");
             return 1;
@@ -4499,8 +4459,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(handlers, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"handlers\" missing from Try");
             return 1;
@@ -4524,8 +4483,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(orelse, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from Try");
             return 1;
@@ -4549,8 +4507,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(finalbody, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"finalbody\" missing from Try");
             return 1;
@@ -4574,8 +4531,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &test, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from Assert");
             return 1;
@@ -4586,8 +4542,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &msg, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             msg = NULL;
         }
@@ -4621,8 +4576,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(names, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Import");
             return 1;
@@ -4646,8 +4600,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_identifier(tmp, &module, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             module = NULL;
         }
@@ -4670,8 +4623,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(names, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from ImportFrom");
             return 1;
@@ -4682,8 +4634,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_int(tmp, &level, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             level = 0;
         }
@@ -4717,8 +4668,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(names, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Global");
             return 1;
@@ -4753,8 +4703,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(names, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"names\" missing from Nonlocal");
             return 1;
@@ -4776,8 +4725,7 @@ obj2ast_stmt(PyObject* obj, stmt_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Expr");
             return 1;
@@ -4842,8 +4790,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_int(tmp, &lineno, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from expr");
         return 1;
@@ -4854,8 +4801,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_int(tmp, &col_offset, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from expr");
         return 1;
@@ -4874,8 +4820,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_boolop(tmp, &op, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BoolOp");
             return 1;
@@ -4899,8 +4844,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(values, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from BoolOp");
             return 1;
@@ -4924,8 +4868,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &left, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from BinOp");
             return 1;
@@ -4936,8 +4879,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_operator(tmp, &op, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from BinOp");
             return 1;
@@ -4948,8 +4890,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &right, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"right\" missing from BinOp");
             return 1;
@@ -4972,8 +4913,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_unaryop(tmp, &op, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"op\" missing from UnaryOp");
             return 1;
@@ -4984,8 +4924,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &operand, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"operand\" missing from UnaryOp");
             return 1;
@@ -5008,8 +4947,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_arguments(tmp, &args, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Lambda");
             return 1;
@@ -5020,8 +4958,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &body, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from Lambda");
             return 1;
@@ -5045,8 +4982,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &test, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"test\" missing from IfExp");
             return 1;
@@ -5057,8 +4993,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &body, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from IfExp");
             return 1;
@@ -5069,8 +5004,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &orelse, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"orelse\" missing from IfExp");
             return 1;
@@ -5106,8 +5040,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(keys, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"keys\" missing from Dict");
             return 1;
@@ -5131,8 +5064,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(values, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"values\" missing from Dict");
             return 1;
@@ -5167,8 +5099,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(elts, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Set");
             return 1;
@@ -5191,8 +5122,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &elt, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from ListComp");
             return 1;
@@ -5216,8 +5146,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(generators, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from ListComp");
             return 1;
@@ -5240,8 +5169,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &elt, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from SetComp");
             return 1;
@@ -5265,8 +5193,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(generators, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from SetComp");
             return 1;
@@ -5290,8 +5217,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &key, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"key\" missing from DictComp");
             return 1;
@@ -5302,8 +5228,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from DictComp");
             return 1;
@@ -5327,8 +5252,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(generators, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from DictComp");
             return 1;
@@ -5351,8 +5275,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &elt, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"elt\" missing from GeneratorExp");
             return 1;
@@ -5376,8 +5299,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(generators, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"generators\" missing from GeneratorExp");
             return 1;
@@ -5399,8 +5321,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             value = NULL;
         }
@@ -5421,8 +5342,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from YieldFrom");
             return 1;
@@ -5446,8 +5366,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &left, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"left\" missing from Compare");
             return 1;
@@ -5471,8 +5390,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(ops, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ops\" missing from Compare");
             return 1;
@@ -5496,8 +5414,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(comparators, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"comparators\" missing from Compare");
             return 1;
@@ -5523,8 +5440,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &func, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"func\" missing from Call");
             return 1;
@@ -5548,8 +5464,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(args, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from Call");
             return 1;
@@ -5573,8 +5488,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(keywords, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"keywords\" missing from Call");
             return 1;
@@ -5585,8 +5499,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &starargs, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             starargs = NULL;
         }
@@ -5596,8 +5509,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &kwargs, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             kwargs = NULL;
         }
@@ -5619,8 +5531,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_object(tmp, &n, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"n\" missing from Num");
             return 1;
@@ -5642,8 +5553,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_string(tmp, &s, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Str");
             return 1;
@@ -5665,8 +5575,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_bytes(tmp, &s, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"s\" missing from Bytes");
             return 1;
@@ -5700,8 +5609,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Attribute");
             return 1;
@@ -5712,8 +5620,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_identifier(tmp, &attr, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"attr\" missing from Attribute");
             return 1;
@@ -5724,8 +5631,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr_context(tmp, &ctx, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Attribute");
             return 1;
@@ -5749,8 +5655,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Subscript");
             return 1;
@@ -5761,8 +5666,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_slice(tmp, &slice, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"slice\" missing from Subscript");
             return 1;
@@ -5773,8 +5677,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr_context(tmp, &ctx, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Subscript");
             return 1;
@@ -5797,8 +5700,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Starred");
             return 1;
@@ -5809,8 +5711,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr_context(tmp, &ctx, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Starred");
             return 1;
@@ -5833,8 +5734,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_identifier(tmp, &id, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"id\" missing from Name");
             return 1;
@@ -5845,8 +5745,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr_context(tmp, &ctx, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Name");
             return 1;
@@ -5882,8 +5781,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(elts, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from List");
             return 1;
@@ -5894,8 +5792,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr_context(tmp, &ctx, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from List");
             return 1;
@@ -5931,8 +5828,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(elts, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"elts\" missing from Tuple");
             return 1;
@@ -5943,8 +5839,7 @@ obj2ast_expr(PyObject* obj, expr_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr_context(tmp, &ctx, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"ctx\" missing from Tuple");
             return 1;
@@ -6044,8 +5939,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &lower, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             lower = NULL;
         }
@@ -6055,8 +5949,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &upper, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             upper = NULL;
         }
@@ -6066,8 +5959,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &step, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             step = NULL;
         }
@@ -6101,8 +5993,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(dims, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"dims\" missing from ExtSlice");
             return 1;
@@ -6124,8 +6015,7 @@ obj2ast_slice(PyObject* obj, slice_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &value, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from Index");
             return 1;
@@ -6419,8 +6309,7 @@ obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &target, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"target\" missing from comprehension");
         return 1;
@@ -6431,8 +6320,7 @@ obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &iter, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"iter\" missing from comprehension");
         return 1;
@@ -6456,8 +6344,7 @@ obj2ast_comprehension(PyObject* obj, comprehension_ty* out, PyArena* arena)
             if (res != 0) goto failed;
             asdl_seq_SET(ifs, i, value);
         }
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"ifs\" missing from comprehension");
         return 1;
@@ -6488,8 +6375,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_int(tmp, &lineno, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"lineno\" missing from excepthandler");
         return 1;
@@ -6500,8 +6386,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_int(tmp, &col_offset, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"col_offset\" missing from excepthandler");
         return 1;
@@ -6521,8 +6406,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_expr(tmp, &type, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             type = NULL;
         }
@@ -6532,8 +6416,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
             if (tmp == NULL) goto failed;
             res = obj2ast_identifier(tmp, &name, arena);
             if (res != 0) goto failed;
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             name = NULL;
         }
@@ -6556,8 +6439,7 @@ obj2ast_excepthandler(PyObject* obj, excepthandler_ty* out, PyArena* arena)
                 if (res != 0) goto failed;
                 asdl_seq_SET(body, i, value);
             }
-            Py_XDECREF(tmp);
-            tmp = NULL;
+            Py_CLEAR(tmp);
         } else {
             PyErr_SetString(PyExc_TypeError, "required field \"body\" missing from ExceptHandler");
             return 1;
@@ -6605,8 +6487,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
             if (res != 0) goto failed;
             asdl_seq_SET(args, i, value);
         }
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"args\" missing from arguments");
         return 1;
@@ -6617,8 +6498,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_identifier(tmp, &vararg, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         vararg = NULL;
     }
@@ -6628,8 +6508,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &varargannotation, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         varargannotation = NULL;
     }
@@ -6652,8 +6531,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
             if (res != 0) goto failed;
             asdl_seq_SET(kwonlyargs, i, value);
         }
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"kwonlyargs\" missing from arguments");
         return 1;
@@ -6664,8 +6542,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_identifier(tmp, &kwarg, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         kwarg = NULL;
     }
@@ -6675,8 +6552,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &kwargannotation, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         kwargannotation = NULL;
     }
@@ -6699,8 +6575,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
             if (res != 0) goto failed;
             asdl_seq_SET(defaults, i, value);
         }
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"defaults\" missing from arguments");
         return 1;
@@ -6724,8 +6599,7 @@ obj2ast_arguments(PyObject* obj, arguments_ty* out, PyArena* arena)
             if (res != 0) goto failed;
             asdl_seq_SET(kw_defaults, i, value);
         }
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"kw_defaults\" missing from arguments");
         return 1;
@@ -6751,8 +6625,7 @@ obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_identifier(tmp, &arg, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from arg");
         return 1;
@@ -6763,8 +6636,7 @@ obj2ast_arg(PyObject* obj, arg_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &annotation, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         annotation = NULL;
     }
@@ -6788,8 +6660,7 @@ obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_identifier(tmp, &arg, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"arg\" missing from keyword");
         return 1;
@@ -6800,8 +6671,7 @@ obj2ast_keyword(PyObject* obj, keyword_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &value, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"value\" missing from keyword");
         return 1;
@@ -6826,8 +6696,7 @@ obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_identifier(tmp, &name, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"name\" missing from alias");
         return 1;
@@ -6838,8 +6707,7 @@ obj2ast_alias(PyObject* obj, alias_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_identifier(tmp, &asname, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         asname = NULL;
     }
@@ -6863,8 +6731,7 @@ obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &context_expr, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         PyErr_SetString(PyExc_TypeError, "required field \"context_expr\" missing from withitem");
         return 1;
@@ -6875,8 +6742,7 @@ obj2ast_withitem(PyObject* obj, withitem_ty* out, PyArena* arena)
         if (tmp == NULL) goto failed;
         res = obj2ast_expr(tmp, &optional_vars, arena);
         if (res != 0) goto failed;
-        Py_XDECREF(tmp);
-        tmp = NULL;
+        Py_CLEAR(tmp);
     } else {
         optional_vars = NULL;
     }