mirror of
https://github.com/python/cpython.git
synced 2025-11-01 18:51:43 +00:00
Sorry, r67092 is commit miss....
This commit is contained in:
parent
1543a22d86
commit
b46a633eaf
2 changed files with 8 additions and 21 deletions
|
|
@ -1963,6 +1963,7 @@ save_reduce(PicklerObject *self, PyObject *args, PyObject *obj)
|
|||
PyObject *state = NULL;
|
||||
PyObject *listitems = Py_None;
|
||||
PyObject *dictitems = Py_None;
|
||||
Py_ssize_t size;
|
||||
|
||||
int use_newobj = self->proto >= 2;
|
||||
|
||||
|
|
@ -1970,6 +1971,13 @@ save_reduce(PicklerObject *self, PyObject *args, PyObject *obj)
|
|||
const char build_op = BUILD;
|
||||
const char newobj_op = NEWOBJ;
|
||||
|
||||
size = PyTuple_Size(args);
|
||||
if (size < 2 || size > 5) {
|
||||
PyErr_SetString(PicklingError, "tuple returned by "
|
||||
"__reduce__ must contain 2 through 5 elements");
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (!PyArg_UnpackTuple(args, "save_reduce", 2, 5,
|
||||
&callable, &argtup, &state, &listitems, &dictitems))
|
||||
return -1;
|
||||
|
|
@ -2146,7 +2154,6 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
|
|||
PyObject *reduce_value = NULL;
|
||||
PyObject *memo_key = NULL;
|
||||
int status = 0;
|
||||
Py_ssize_t size;
|
||||
|
||||
if (Py_EnterRecursiveCall(" while pickling an object") < 0)
|
||||
return -1;
|
||||
|
|
@ -2325,13 +2332,6 @@ save(PicklerObject *self, PyObject *obj, int pers_save)
|
|||
goto error;
|
||||
}
|
||||
|
||||
size = PyTuple_Size(reduce_value);
|
||||
if (size < 2 || size > 5) {
|
||||
PyErr_SetString(PicklingError, "tuple returned by "
|
||||
"__reduce__ must contain 2 through 5 elements");
|
||||
goto error;
|
||||
}
|
||||
|
||||
status = save_reduce(self, reduce_value, obj);
|
||||
|
||||
if (0) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue