diff options
author | Tim Peters <tim.peters@gmail.com> | 2004-06-07 23:04:33 (GMT) |
---|---|---|
committer | Tim Peters <tim.peters@gmail.com> | 2004-06-07 23:04:33 (GMT) |
commit | 604c013ef2747e70fa5f3140eb36d9969606070e (patch) | |
tree | 9678f32052d99737e23e085d242f88a93b125362 /Modules | |
parent | d348193ff2bbf8b007f9cabd7fc81ab3491464e3 (diff) | |
download | cpython-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.c | 9 |
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); |