summaryrefslogtreecommitdiffstats
path: root/Modules/datetimemodule.c
diff options
context:
space:
mode:
authorAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-06-23 21:40:15 (GMT)
committerAlexander Belopolsky <alexander.belopolsky@gmail.com>2010-06-23 21:40:15 (GMT)
commit1b7046b99e2369175c19532a788e722daf7c65f0 (patch)
treefe4097e8e160a3dfd81cee18ff946e25733f60f9 /Modules/datetimemodule.c
parentb7e10100968af7e4c56543e45eced93e75448d27 (diff)
downloadcpython-1b7046b99e2369175c19532a788e722daf7c65f0.zip
cpython-1b7046b99e2369175c19532a788e722daf7c65f0.tar.gz
cpython-1b7046b99e2369175c19532a788e722daf7c65f0.tar.bz2
Issue #9051: Instances of timezone class can now be pickled.
Diffstat (limited to 'Modules/datetimemodule.c')
-rw-r--r--Modules/datetimemodule.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 8b3cc06..507d2bb 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -3469,6 +3469,14 @@ timezone_fromutc(PyDateTime_TimeZone *self, PyDateTime_DateTime *dt)
return add_datetime_timedelta(dt, (PyDateTime_Delta *)self->offset, 1);
}
+static PyObject *
+timezone_getinitargs(PyDateTime_TimeZone *self)
+{
+ if (self->name == NULL)
+ return Py_BuildValue("(O)", self->offset);
+ return Py_BuildValue("(OO)", self->offset, self->name);
+}
+
static PyMethodDef timezone_methods[] = {
{"tzname", (PyCFunction)timezone_tzname, METH_O,
PyDoc_STR("If name is specified when timezone is created, returns the name."
@@ -3483,6 +3491,9 @@ static PyMethodDef timezone_methods[] = {
{"fromutc", (PyCFunction)timezone_fromutc, METH_O,
PyDoc_STR("datetime in UTC -> datetime in local time.")},
+ {"__getinitargs__", (PyCFunction)timezone_getinitargs, METH_NOARGS,
+ PyDoc_STR("pickle support")},
+
{NULL, NULL}
};