summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorAntoine Pitrou <solipsis@pitrou.net>2011-01-23 17:21:28 (GMT)
committerAntoine Pitrou <solipsis@pitrou.net>2011-01-23 17:21:28 (GMT)
commit0f2a61a11eccea4d4ecddc30147116aae5ec09ab (patch)
treebf064181dc86da53fad70677b8ff5ab85b2a5091 /Modules
parenteb9d5ad6ba3153d2016d6708e1a3b63ea740e149 (diff)
downloadcpython-0f2a61a11eccea4d4ecddc30147116aae5ec09ab.zip
cpython-0f2a61a11eccea4d4ecddc30147116aae5ec09ab.tar.gz
cpython-0f2a61a11eccea4d4ecddc30147116aae5ec09ab.tar.bz2
Merged revisions 88147 via svnmerge from
svn+ssh://pythondev@svn.python.org/python/branches/py3k ........ r88147 | antoine.pitrou | 2011-01-23 18:12:25 +0100 (dim., 23 janv. 2011) | 3 lines Issue #10987: Fix the recursion limit handling in the _pickle module. ........
Diffstat (limited to 'Modules')
-rw-r--r--Modules/_pickle.c20
1 files changed, 15 insertions, 5 deletions
diff --git a/Modules/_pickle.c b/Modules/_pickle.c
index c47a844..4eb74ff 100644
--- a/Modules/_pickle.c
+++ b/Modules/_pickle.c
@@ -1566,7 +1566,12 @@ save_list(PicklerObject *self, PyObject *obj)
iter = PyObject_GetIter(obj);
if (iter == NULL)
goto error;
+ if (Py_EnterRecursiveCall(" while pickling an object")) {
+ Py_DECREF(iter);
+ goto error;
+ }
status = batch_list(self, iter);
+ Py_LeaveRecursiveCall();
Py_DECREF(iter);
}
@@ -1814,10 +1819,10 @@ save_dict(PicklerObject *self, PyObject *obj)
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)
@@ -1826,7 +1831,12 @@ save_dict(PicklerObject *self, PyObject *obj)
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);
}
}
@@ -2353,7 +2363,7 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
PyObject *memo_key = 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()