summaryrefslogtreecommitdiffstats
path: root/Modules
diff options
context:
space:
mode:
authorTim Peters <tim.peters@gmail.com>2004-06-07 23:04:33 (GMT)
committerTim Peters <tim.peters@gmail.com>2004-06-07 23:04:33 (GMT)
commit604c013ef2747e70fa5f3140eb36d9969606070e (patch)
tree9678f32052d99737e23e085d242f88a93b125362 /Modules
parentd348193ff2bbf8b007f9cabd7fc81ab3491464e3 (diff)
downloadcpython-604c013ef2747e70fa5f3140eb36d9969606070e.zip
cpython-604c013ef2747e70fa5f3140eb36d9969606070e.tar.gz
cpython-604c013ef2747e70fa5f3140eb36d9969606070e.tar.bz2
SF 952807: Unpickling pickled instances of subclasses of datetime.date,
datetime.datetime and datetime.time could yield insane objects. Thanks to Jiwon Seo for the fix. Bugfix candidate. I'll backport it to 2.3.
Diffstat (limited to 'Modules')
-rw-r--r--Modules/datetimemodule.c9
1 files changed, 3 insertions, 6 deletions
diff --git a/Modules/datetimemodule.c b/Modules/datetimemodule.c
index 225a6b1..7f38d1a 100644
--- a/Modules/datetimemodule.c
+++ b/Modules/datetimemodule.c
@@ -2206,7 +2206,7 @@ date_new(PyTypeObject *type, PyObject *args, PyObject *kw)
{
PyDateTime_Date *me;
- me = PyObject_New(PyDateTime_Date, type);
+ me = (PyDateTime_Date *) (type->tp_alloc(type, 0));
if (me != NULL) {
char *pdata = PyString_AS_STRING(state);
memcpy(me->data, pdata, _PyDateTime_DATE_DATASIZE);
@@ -3049,8 +3049,7 @@ time_new(PyTypeObject *type, PyObject *args, PyObject *kw)
}
}
aware = (char)(tzinfo != Py_None);
- me = (PyDateTime_Time *) time_alloc(&PyDateTime_TimeType,
- aware);
+ me = (PyDateTime_Time *) (type->tp_alloc(type, aware));
if (me != NULL) {
char *pdata = PyString_AS_STRING(state);
@@ -3572,9 +3571,7 @@ datetime_new(PyTypeObject *type, PyObject *args, PyObject *kw)
}
}
aware = (char)(tzinfo != Py_None);
- me = (PyDateTime_DateTime *) datetime_alloc(
- &PyDateTime_DateTimeType,
- aware);
+ me = (PyDateTime_DateTime *) (type->tp_alloc(type , aware));
if (me != NULL) {
char *pdata = PyString_AS_STRING(state);