Issue #18408: Fix Py_ReprEnter(), handle PyList_Append() failure
diff --git a/Objects/object.c b/Objects/object.c
index 700e8be..e957d9d 100644
--- a/Objects/object.c
+++ b/Objects/object.c
@@ -1910,7 +1910,8 @@
         if (PyList_GET_ITEM(list, i) == obj)
             return 1;
     }
-    PyList_Append(list, obj);
+    if (PyList_Append(list, obj) < 0)
+        return -1;
     return 0;
 }