summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2003-02-01 01:47:29 (GMT)
committerTim Peters <tim.peters@gmail.com>2003-02-01 01:47:29 (GMT)
commit8a60c2238bf65daa8f6558ef6cf04191dbfdb5fe (patch)
tree1054b827528a9657424655d69bfacca39c313584
parent96ef8115dd6ed006f5fc44fa1b577db23485224c (diff)
downloadcpython-8a60c2238bf65daa8f6558ef6cf04191dbfdb5fe.zip
cpython-8a60c2238bf65daa8f6558ef6cf04191dbfdb5fe.tar.gz
cpython-8a60c2238bf65daa8f6558ef6cf04191dbfdb5fe.tar.bz2
delta_setstate(): This waS no longer referenced, so nukeit.
delta_reduce(): Simplified.
-rw-r--r--Modules/datetimemodule.c40
1 files changed, 2 insertions, 38 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 48635e7..029bed3 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -1947,9 +1947,7 @@ delta_str(PyDateTime_Delta *self)
return NULL;
}
-/* Pickle support. Quite a maze! While __getstate__/__setstate__ sufficed
- * in the Python implementation, the C implementation also requires
- * __reduce__, and a __safe_for_unpickling__ attr in the type object.
+/* Pickle support. This is a plain application of __reduce__.
*/
static PyObject *
delta_getstate(PyDateTime_Delta *self)
@@ -1959,44 +1957,10 @@ delta_getstate(PyDateTime_Delta *self)
GET_TD_MICROSECONDS(self));
}
-/* __setstate__ isn't exposed. */
-static PyObject *
-delta_setstate(PyDateTime_Delta *self, PyObject *state)
-{
- int day;
- int second;
- int us;
-
- if (!PyArg_ParseTuple(state, "iii:__setstate__", &day, &second, &us))
- return NULL;
-
- self->hashcode = -1;
- SET_TD_DAYS(self, day);
- SET_TD_SECONDS(self, second);
- SET_TD_MICROSECONDS(self, us);
-
- Py_INCREF(Py_None);
- return Py_None;
-}
-
static PyObject *
delta_reduce(PyDateTime_Delta* self)
{
- PyObject* result = NULL;
- PyObject* state = delta_getstate(self);
-
- if (state != NULL) {
- /* The funky "()" in the format string creates an empty
- * tuple as the 2nd component of the result 3-tuple.
- */
- result = Py_BuildValue("O(iii)",
- self->ob_type,
- self->days,
- self->seconds,
- self->microseconds);
- Py_DECREF(state);
- }
- return result;
+ return Py_BuildValue("ON", self->ob_type, delta_getstate(self));
}
#define OFFSET(field) offsetof(PyDateTime_Delta, field)