only finish error if one occurred
diff --git a/Python/ast.c b/Python/ast.c
index 66b85b5..ef161b6 100644
--- a/Python/ast.c
+++ b/Python/ast.c
@@ -835,7 +835,8 @@
         PyTuple_SET_ITEM(c.c_normalize_args, 1, NULL);
         Py_DECREF(c.c_normalize_args);
     }
-    ast_error_finish(filename);
+    if (!res)
+        ast_error_finish(filename);
     return res;
 }