[Python-checkins] python/dist/src/Objects typeobject.c,2.212,2.213
gvanrossum@users.sourceforge.net
gvanrossum@users.sourceforge.net
Tue, 18 Feb 2003 14:05:43 -0800
Update of /cvsroot/python/python/dist/src/Objects
In directory sc8-pr-cvs1:/tmp/cvs-serv10437/Objects
Modified Files:
typeobject.c
Log Message:
Introducing __reduce_ex__, which is called with a protocol number argument
if it exists in preference over __reduce__. Now Tim can go implement this
in cPickle.c.
Index: typeobject.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Objects/typeobject.c,v
retrieving revision 2.212
retrieving revision 2.213
diff -C2 -d -r2.212 -r2.213
*** typeobject.c 18 Feb 2003 19:32:50 -0000 2.212
--- typeobject.c 18 Feb 2003 22:05:09 -0000 2.213
***************
*** 2442,2450 ****
static PyObject *
! object_reduce(PyObject *self, PyObject *args)
{
! /* Call copy_reg._reduce(self) */
static PyObject *copy_reg_str;
PyObject *copy_reg, *res;
if (!copy_reg_str) {
--- 2442,2454 ----
static PyObject *
! object_reduce_ex(PyObject *self, PyObject *args)
{
! /* Call copy_reg._reduce_ex(self, proto) */
static PyObject *copy_reg_str;
PyObject *copy_reg, *res;
+ int proto = 0;
+
+ if (!PyArg_ParseTuple(args, "|i:__reduce_ex__", &proto))
+ return NULL;
if (!copy_reg_str) {
***************
*** 2456,2460 ****
if (!copy_reg)
return NULL;
! res = PyEval_CallMethod(copy_reg, "_reduce", "(O)", self);
Py_DECREF(copy_reg);
return res;
--- 2460,2464 ----
if (!copy_reg)
return NULL;
! res = PyEval_CallMethod(copy_reg, "_reduce_ex", "(Oi)", self, proto);
Py_DECREF(copy_reg);
return res;
***************
*** 2462,2466 ****
static PyMethodDef object_methods[] = {
! {"__reduce__", object_reduce, METH_NOARGS,
PyDoc_STR("helper for pickle")},
{0}
--- 2466,2472 ----
static PyMethodDef object_methods[] = {
! {"__reduce_ex__", object_reduce_ex, METH_VARARGS,
! PyDoc_STR("helper for pickle")},
! {"__reduce__", object_reduce_ex, METH_VARARGS,
PyDoc_STR("helper for pickle")},
{0}