if (len != 0) {
/* Materialize the list elements. */
if (PyList_CheckExact(obj) && self->proto > 0) {
- if (Py_EnterRecursiveCall(" while pickling an object") == 0) {
- status = batch_list_exact(self, obj);
- Py_LeaveRecursiveCall();
- }
+ if (Py_EnterRecursiveCall(" while pickling an object"))
+ goto error;
+ status = batch_list_exact(self, obj);
+ Py_LeaveRecursiveCall();
} else {
PyObject *iter = PyObject_GetIter(obj);
if (iter == NULL)
goto error;
- if (Py_EnterRecursiveCall(" while pickling an object") == 0) {
- status = batch_list(self, iter);
- Py_LeaveRecursiveCall();
+ if (Py_EnterRecursiveCall(" while pickling an object")) {
+ Py_DECREF(iter);
+ goto error;
}
+ status = batch_list(self, iter);
+ Py_LeaveRecursiveCall();
Py_DECREF(iter);
}
}
if (PyDict_CheckExact(obj) && self->proto > 0) {
/* We can take certain shortcuts if we know this is a dict and
not a dict subclass. */
- if (Py_EnterRecursiveCall(" while pickling an object") == 0) {
- status = batch_dict_exact(self, obj);
- Py_LeaveRecursiveCall();
- }
+ if (Py_EnterRecursiveCall(" while pickling an object"))
+ goto error;
+ status = batch_dict_exact(self, obj);
+ Py_LeaveRecursiveCall();
} else {
items = PyObject_CallMethod(obj, "items", "()");
if (items == NULL)
Py_DECREF(items);
if (iter == NULL)
goto error;
+ if (Py_EnterRecursiveCall(" while pickling an object")) {
+ Py_DECREF(iter);
+ goto error;
+ }
status = batch_dict(self, iter);
+ Py_LeaveRecursiveCall();
Py_DECREF(iter);
}
}
PyObject *reduce_value = NULL;
int status = 0;
- if (Py_EnterRecursiveCall(" while pickling an object") < 0)
+ if (Py_EnterRecursiveCall(" while pickling an object"))
return -1;
/* The extra pers_save argument is necessary to avoid calling save_pers()