[Python-checkins] python/dist/src/Modules datetimemodule.c,1.34,1.35

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Wed, 08 Jan 2003 12:51:41 -0800


Update of /cvsroot/python/python/dist/src/Modules
In directory sc8-pr-cvs1:/tmp/cvs-serv10350/python/Modules

Modified Files:
	datetimemodule.c 
Log Message:
Deleted pickle/unpickle code for the old datetime and time classes -- it's
unreachable now.


Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.34
retrieving revision 1.35
diff -C2 -d -r1.34 -r1.35
*** datetimemodule.c	8 Jan 2003 20:40:01 -0000	1.34
--- datetimemodule.c	8 Jan 2003 20:51:36 -0000	1.35
***************
*** 1400,1407 ****
  /* Callables to support unpickling. */
  static PyObject *date_unpickler_object = NULL;
- static PyObject *datetime_unpickler_object = NULL;
  static PyObject *datetimetz_unpickler_object = NULL;
  static PyObject *tzinfo_unpickler_object = NULL;
- static PyObject *time_unpickler_object = NULL;
  static PyObject *timetz_unpickler_object = NULL;
  
--- 1400,1405 ----
***************
*** 3381,3430 ****
  }
  
- /* XXX This seems a ridiculously inefficient way to pickle a short string. */
- static PyObject *
- datetime_pickler(PyObject *module, PyDateTime_DateTime *datetime)
- {
- 	PyObject *state;
- 	PyObject *result = NULL;
- 
- 	if (! PyDateTime_CheckExact(datetime)) {
- 		PyErr_Format(PyExc_TypeError,
- 			     "bad type passed to datetime pickler: %s",
- 			     datetime->ob_type->tp_name);
- 		return NULL;
- 	}
- 	state = datetime_getstate(datetime);
- 	if (state) {
- 		result = Py_BuildValue("O(O)",
- 				       datetime_unpickler_object,
- 				       state);
- 		Py_DECREF(state);
- 	}
- 	return result;
- }
- 
- static PyObject *
- datetime_unpickler(PyObject *module, PyObject *arg)
- {
- 	PyDateTime_DateTime *self;
- 
- 	if (! PyString_CheckExact(arg)) {
- 		PyErr_Format(PyExc_TypeError,
- 			     "bad type passed to datetime unpickler: %s",
- 			     arg->ob_type->tp_name);
- 		return NULL;
- 	}
- 	self = PyObject_New(PyDateTime_DateTime, &PyDateTime_DateTimeType);
- 	if (self != NULL) {
- 		PyObject *res = datetime_setstate(self, arg);
- 		if (res == NULL) {
- 			Py_DECREF(self);
- 			return NULL;
- 		}
- 		Py_DECREF(res);
- 	}
- 	return (PyObject *)self;
- }
- 
  static PyMethodDef datetime_methods[] = {
  	/* Class methods: */
--- 3379,3382 ----
***************
*** 3850,3899 ****
  }
  
- /* XXX This seems a ridiculously inefficient way to pickle a short string. */
- static PyObject *
- time_pickler(PyObject *module, PyDateTime_Time *time)
- {
- 	PyObject *state;
- 	PyObject *result = NULL;
- 
- 	if (! PyTime_CheckExact(time)) {
- 		PyErr_Format(PyExc_TypeError,
- 			     "bad type passed to time pickler: %s",
- 			     time->ob_type->tp_name);
- 		return NULL;
- 	}
- 	state = time_getstate(time);
- 	if (state) {
- 		result = Py_BuildValue("O(O)",
- 				       time_unpickler_object,
- 				       state);
- 		Py_DECREF(state);
- 	}
- 	return result;
- }
- 
- static PyObject *
- time_unpickler(PyObject *module, PyObject *arg)
- {
- 	PyDateTime_Time *self;
- 
- 	if (! PyString_CheckExact(arg)) {
- 		PyErr_Format(PyExc_TypeError,
- 			     "bad type passed to time unpickler: %s",
- 			     arg->ob_type->tp_name);
- 		return NULL;
- 	}
- 	self = PyObject_New(PyDateTime_Time, &PyDateTime_TimeType);
- 	if (self != NULL) {
- 		PyObject *res = time_setstate(self, arg);
- 		if (res == NULL) {
- 			Py_DECREF(self);
- 			return NULL;
- 		}
- 		Py_DECREF(res);
- 	}
- 	return (PyObject *)self;
- }
- 
  static PyMethodDef time_methods[] = {
  	{"isoformat",   (PyCFunction)time_isoformat,	METH_KEYWORDS,
--- 3802,3805 ----
***************
*** 5171,5180 ****
  	{"_date_pickler",	(PyCFunction)date_pickler,	METH_O, NULL},
  	{"_date_unpickler",	(PyCFunction)date_unpickler, 	METH_O, NULL},
- 	{"_datetime_pickler",	(PyCFunction)datetime_pickler,	METH_O, NULL},
- 	{"_datetime_unpickler",	(PyCFunction)datetime_unpickler,METH_O, NULL},
  	{"_datetimetz_pickler",	(PyCFunction)datetimetz_pickler,METH_O, NULL},
  	{"_datetimetz_unpickler",(PyCFunction)datetimetz_unpickler,METH_O, NULL},
- 	{"_time_pickler",	(PyCFunction)time_pickler,	METH_O, NULL},
- 	{"_time_unpickler",	(PyCFunction)time_unpickler,	METH_O, NULL},
  	{"_timetz_pickler",	(PyCFunction)timetz_pickler,	METH_O, NULL},
  	{"_timetz_unpickler",	(PyCFunction)timetz_unpickler,	METH_O, NULL},
--- 5077,5082 ----
***************
*** 5237,5266 ****
  		Py_DECREF(pickler);
  
- 		pickler = PyObject_GetAttrString(m, "_datetime_pickler");
- 		if (pickler == NULL) return;
- 		datetime_unpickler_object = PyObject_GetAttrString(m,
- 						"_datetime_unpickler");
- 		if (datetime_unpickler_object == NULL) return;
- 	    	x = PyObject_CallMethod(copyreg, "pickle", "OOO",
- 	    				&PyDateTime_DateTimeType,
- 	    				pickler,
- 		                    	datetime_unpickler_object);
- 		if (x == NULL) return;
- 		Py_DECREF(x);
- 		Py_DECREF(pickler);
- 
- 		pickler = PyObject_GetAttrString(m, "_time_pickler");
- 		if (pickler == NULL) return;
- 		time_unpickler_object = PyObject_GetAttrString(m,
- 						"_time_unpickler");
- 		if (time_unpickler_object == NULL) return;
- 	    	x = PyObject_CallMethod(copyreg, "pickle", "OOO",
- 	    				&PyDateTime_TimeType,
- 	    				pickler,
- 		                	time_unpickler_object);
- 		if (x == NULL) return;
- 		Py_DECREF(x);
- 		Py_DECREF(pickler);
- 
  		pickler = PyObject_GetAttrString(m, "_timetz_pickler");
  		if (pickler == NULL) return;
--- 5139,5142 ----
***************
*** 5340,5379 ****
  
  	x = new_delta(1, 0, 0, 0);
- 	if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
- 		return;
- 	Py_DECREF(x);
- 
- 	/* datetime values */
- 	d = PyDateTime_DateTimeType.tp_dict;
- 
- 	x = new_datetime(1, 1, 1, 0, 0, 0, 0);
- 	if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- 		return;
- 	Py_DECREF(x);
- 
- 	x = new_datetime(MAXYEAR, 12, 31, 23, 59, 59, 999999);
- 	if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- 		return;
- 	Py_DECREF(x);
- 
- 	x = new_delta(0, 0, 1, 0);
- 	if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
- 		return;
- 	Py_DECREF(x);
- 
- 	/* time values */
- 	d = PyDateTime_TimeType.tp_dict;
- 
- 	x = new_time(0, 0, 0, 0);
- 	if (x == NULL || PyDict_SetItemString(d, "min", x) < 0)
- 		return;
- 	Py_DECREF(x);
- 
- 	x = new_time(23, 59, 59, 999999);
- 	if (x == NULL || PyDict_SetItemString(d, "max", x) < 0)
- 		return;
- 	Py_DECREF(x);
- 
- 	x = new_delta(0, 0, 1, 0);
  	if (x == NULL || PyDict_SetItemString(d, "resolution", x) < 0)
  		return;
--- 5216,5219 ----