summaryrefslogtreecommitdiff
path: root/Parser/asdl_c.py
diff options
context:
space:
mode:
Diffstat (limited to 'Parser/asdl_c.py')
-rwxr-xr-xParser/asdl_c.py10
1 files changed, 7 insertions, 3 deletions
diff --git a/Parser/asdl_c.py b/Parser/asdl_c.py
index 25682229cc..e61aae24d1 100755
--- a/Parser/asdl_c.py
+++ b/Parser/asdl_c.py
@@ -834,9 +834,13 @@ static int obj2ast_object(PyObject* obj, PyObject** out, PyArena* arena)
{
if (obj == Py_None)
obj = NULL;
- if (obj)
- PyArena_AddPyObject(arena, obj);
- Py_XINCREF(obj);
+ if (obj) {
+ if (PyArena_AddPyObject(arena, obj) < 0) {
+ *out = NULL;
+ return -1;
+ }
+ Py_INCREF(obj);
+ }
*out = obj;
return 0;
}