[Python-checkins] python/dist/src/Modules datetimemodule.c,1.35,1.36
tim_one@users.sourceforge.net
tim_one@users.sourceforge.net
Thu, 09 Jan 2003 18:05:18 -0800
Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv654/python/Modules
Modified Files:
datetimemodule.c
Log Message:
Removed more now-pointless pickle code.
Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.35
retrieving revision 1.36
diff -C2 -d -r1.35 -r1.36
*** datetimemodule.c 8 Jan 2003 20:51:36 -0000 1.35
--- datetimemodule.c 10 Jan 2003 02:05:14 -0000 1.36
***************
*** 622,626 ****
assert(check_tzinfo_subclass(newtzinfo) >= 0);
Py_INCREF(newtzinfo);
! Py_DECREF(((PyDateTime_DateTimeTZ *)self)->tzinfo);
((PyDateTime_DateTimeTZ *)self)->tzinfo = newtzinfo;
}
--- 622,626 ----
assert(check_tzinfo_subclass(newtzinfo) >= 0);
Py_INCREF(newtzinfo);
! Py_XDECREF(((PyDateTime_DateTimeTZ *)self)->tzinfo);
((PyDateTime_DateTimeTZ *)self)->tzinfo = newtzinfo;
}
***************
*** 3234,3239 ****
}
- static PyObject *datetime_getstate(PyDateTime_DateTime *self);
-
static long
datetime_hash(PyDateTime_DateTime *self)
--- 3234,3237 ----
***************
*** 3252,3256 ****
/* Reduce this to a hash of another object. */
if (n == OFFSET_NAIVE)
! temp = datetime_getstate(self);
else {
int days;
--- 3250,3256 ----
/* Reduce this to a hash of another object. */
if (n == OFFSET_NAIVE)
! temp = PyString_FromStringAndSize(
! (char *)self->data,
! _PyDateTime_DATETIME_DATASIZE);
else {
int days;
***************
*** 3351,3382 ****
}
- /* Pickle support. Quite a maze! */
-
- static PyObject *
- datetime_getstate(PyDateTime_DateTime *self)
- {
- return PyString_FromStringAndSize((char *)self->data,
- _PyDateTime_DATETIME_DATASIZE);
- }
-
- static PyObject *
- datetime_setstate(PyDateTime_DateTime *self, PyObject *state)
- {
- const int len = PyString_Size(state);
- unsigned char *pdata = (unsigned char*)PyString_AsString(state);
-
- if (! PyString_Check(state) ||
- len != _PyDateTime_DATETIME_DATASIZE) {
- PyErr_SetString(PyExc_TypeError,
- "bad argument to datetime.__setstate__");
- return NULL;
- }
- memcpy(self->data, pdata, _PyDateTime_DATETIME_DATASIZE);
- self->hashcode = -1;
-
- Py_INCREF(Py_None);
- return Py_None;
- }
-
static PyMethodDef datetime_methods[] = {
/* Class methods: */
--- 3351,3354 ----
***************
*** 3429,3437 ****
PyDoc_STR("tz -> datetimetz with same date & time, and tzinfo=tz\n")},
- {"__setstate__", (PyCFunction)datetime_setstate, METH_O,
- PyDoc_STR("__setstate__(state)")},
-
- {"__getstate__", (PyCFunction)datetime_getstate, METH_NOARGS,
- PyDoc_STR("__getstate__() -> state")},
{NULL, NULL}
};
--- 3401,3404 ----
***************
*** 3697,3702 ****
}
- static PyObject *time_getstate(PyDateTime_Time *self);
-
static long
time_hash(PyDateTime_Time *self)
--- 3664,3667 ----
***************
*** 3714,3718 ****
/* Reduce this to a hash of another object. */
if (offset == 0)
! temp = time_getstate(self);
else {
int hour;
--- 3679,3684 ----
/* Reduce this to a hash of another object. */
if (offset == 0)
! temp = PyString_FromStringAndSize((char *)self->data,
! _PyDateTime_TIME_DATASIZE);
else {
int hour;
***************
*** 3774,3805 ****
}
- /* Pickle support. Quite a maze! */
-
- static PyObject *
- time_getstate(PyDateTime_Time *self)
- {
- return PyString_FromStringAndSize((char *)self->data,
- _PyDateTime_TIME_DATASIZE);
- }
-
- static PyObject *
- time_setstate(PyDateTime_Time *self, PyObject *state)
- {
- const int len = PyString_Size(state);
- unsigned char *pdata = (unsigned char*)PyString_AsString(state);
-
- if (! PyString_Check(state) ||
- len != _PyDateTime_TIME_DATASIZE) {
- PyErr_SetString(PyExc_TypeError,
- "bad argument to time.__setstate__");
- return NULL;
- }
- memcpy(self->data, pdata, _PyDateTime_TIME_DATASIZE);
- self->hashcode = -1;
-
- Py_INCREF(Py_None);
- return Py_None;
- }
-
static PyMethodDef time_methods[] = {
{"isoformat", (PyCFunction)time_isoformat, METH_KEYWORDS,
--- 3740,3743 ----
***************
*** 3811,3820 ****
{"replace", (PyCFunction)time_replace, METH_KEYWORDS,
PyDoc_STR("Return datetime with new specified fields.")},
-
- {"__setstate__", (PyCFunction)time_setstate, METH_O,
- PyDoc_STR("__setstate__(state)")},
-
- {"__getstate__", (PyCFunction)time_getstate, METH_NOARGS,
- PyDoc_STR("__getstate__() -> state")},
{NULL, NULL}
};
--- 3749,3752 ----
***************
*** 4177,4181 ****
*/
! /* Let basestate be the state string returned by time_getstate.
* If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
* So it's a tuple in any (non-error) case.
--- 4109,4113 ----
*/
! /* Let basestate be the non-tzinfo data string.
* If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
* So it's a tuple in any (non-error) case.
***************
*** 4187,4191 ****
PyObject *result = NULL;
! basestate = time_getstate((PyDateTime_Time *)self);
if (basestate != NULL) {
if (self->tzinfo == Py_None)
--- 4119,4124 ----
PyObject *result = NULL;
! basestate = PyString_FromStringAndSize((char *)self->data,
! _PyDateTime_TIME_DATASIZE);
if (basestate != NULL) {
if (self->tzinfo == Py_None)
***************
*** 4201,4205 ****
timetz_setstate(PyDateTime_TimeTZ *self, PyObject *state)
{
- PyObject *temp;
PyObject *basestate;
PyObject *tzinfo = Py_None;
--- 4134,4137 ----
***************
*** 4209,4221 ****
&tzinfo))
return NULL;
! temp = time_setstate((PyDateTime_Time *)self, basestate);
! if (temp == NULL)
return NULL;
! Py_DECREF(temp);
!
Py_INCREF(tzinfo);
Py_XDECREF(self->tzinfo);
self->tzinfo = tzinfo;
-
Py_INCREF(Py_None);
return Py_None;
--- 4141,4157 ----
&tzinfo))
return NULL;
! if (PyString_Size(basestate) != _PyDateTime_TIME_DATASIZE ||
! check_tzinfo_subclass(tzinfo) < 0) {
! PyErr_SetString(PyExc_TypeError,
! "bad argument to time.__setstate__");
return NULL;
! }
! memcpy((char *)self->data,
! PyString_AsString(basestate),
! _PyDateTime_TIME_DATASIZE);
! self->hashcode = -1;
Py_INCREF(tzinfo);
Py_XDECREF(self->tzinfo);
self->tzinfo = tzinfo;
Py_INCREF(Py_None);
return Py_None;
***************
*** 4865,4869 ****
*/
! /* Let basestate be the state string returned by datetime_getstate.
* If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
* So it's a tuple in any (non-error) case.
--- 4801,4808 ----
*/
!
! /* Pickle support. Quite a maze! */
!
! /* Let basestate be the state string returned by the date & time fields.
* If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
* So it's a tuple in any (non-error) case.
***************
*** 4875,4879 ****
PyObject *result = NULL;
! basestate = datetime_getstate((PyDateTime_DateTime *)self);
if (basestate != NULL) {
if (self->tzinfo == Py_None)
--- 4814,4819 ----
PyObject *result = NULL;
! basestate = PyString_FromStringAndSize((char *)self->data,
! _PyDateTime_DATETIME_DATASIZE);
if (basestate != NULL) {
if (self->tzinfo == Py_None)
***************
*** 4889,4893 ****
datetimetz_setstate(PyDateTime_DateTimeTZ *self, PyObject *state)
{
- PyObject *temp;
PyObject *basestate;
PyObject *tzinfo = Py_None;
--- 4829,4832 ----
***************
*** 4897,4909 ****
&tzinfo))
return NULL;
! temp = datetime_setstate((PyDateTime_DateTime *)self, basestate);
! if (temp == NULL)
return NULL;
! Py_DECREF(temp);
!
! Py_INCREF(tzinfo);
! Py_XDECREF(self->tzinfo);
! self->tzinfo = tzinfo;
!
Py_INCREF(Py_None);
return Py_None;
--- 4836,4850 ----
&tzinfo))
return NULL;
! if (PyString_Size(basestate) != _PyDateTime_DATETIME_DATASIZE ||
! check_tzinfo_subclass(tzinfo) < 0) {
! PyErr_SetString(PyExc_TypeError,
! "bad argument to datetime.__setstate__");
return NULL;
! }
! memcpy((char *)self->data,
! PyString_AsString(basestate),
! _PyDateTime_DATETIME_DATASIZE);
! self->hashcode = -1;
! replace_tzinfo((PyObject *)self, tzinfo);
Py_INCREF(Py_None);
return Py_None;