[Python-checkins] python/dist/src/Modules datetimemodule.c,1.54,1.55

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Fri, 31 Jan 2003 18:54:18 -0800


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

Modified Files:
	datetimemodule.c 
Log Message:
There's no good reason for datetime objects to expose __getstate__()
anymore either, so don't.  This also allows to get rid of obscure code
making __getnewargs__ identical to __getstate__ (hmm ... hope there
wasn't more to this than I realize!).


Index: datetimemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/datetimemodule.c,v
retrieving revision 1.54
retrieving revision 1.55
diff -C2 -d -r1.54 -r1.55
*** datetimemodule.c	1 Feb 2003 02:16:37 -0000	1.54
--- datetimemodule.c	1 Feb 2003 02:54:15 -0000	1.55
***************
*** 1950,1953 ****
--- 1950,1954 ----
  /* Pickle support, a simple use of __reduce__. */
  
+ /* __getstate__ isn't exposed */
  static PyObject *
  delta_getstate(PyDateTime_Delta *self)
***************
*** 1980,1986 ****
  
  static PyMethodDef delta_methods[] = {
- 	{"__getstate__", (PyCFunction)delta_getstate, METH_NOARGS,
- 	 PyDoc_STR("__getstate__() -> state")},
- 
  	{"__reduce__", (PyCFunction)delta_reduce,     METH_NOARGS,
  	 PyDoc_STR("__reduce__() -> (cls, state)")},
--- 1981,1984 ----
***************
*** 2526,2529 ****
--- 2524,2528 ----
  /* Pickle support, a simple use of __reduce__. */
  
+ /* __getstate__ isn't exposed */
  static PyObject *
  date_getstate(PyDateTime_Date *self)
***************
*** 2592,2598 ****
  	 PyDoc_STR("Return date with new specified fields.")},
  
- 	{"__getstate__", (PyCFunction)date_getstate,	METH_NOARGS,
- 	 PyDoc_STR("__getstate__() -> state")},
- 
  	{"__reduce__", (PyCFunction)date_reduce,        METH_NOARGS,
  	 PyDoc_STR("__reduce__() -> (cls, state)")},
--- 2591,2594 ----
***************
*** 3341,3344 ****
--- 3337,3341 ----
   * If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
   * So it's a tuple in any (non-error) case.
+  * __getstate__ isn't exposed.
   */
  static PyObject *
***************
*** 3387,3393 ****
  	 PyDoc_STR("Return time with new specified fields.")},
  
- 	{"__getstate__", (PyCFunction)time_getstate,	METH_NOARGS,
- 	 PyDoc_STR("__getstate__() -> state")},
- 
  	{"__reduce__", (PyCFunction)time_reduce,        METH_NOARGS,
  	 PyDoc_STR("__reduce__() -> (cls, state)")},
--- 3384,3387 ----
***************
*** 4341,4344 ****
--- 4335,4339 ----
   * If tzinfo is None, this returns (basestate,), else (basestate, tzinfo).
   * So it's a tuple in any (non-error) case.
+  * __getstate__ isn't exposed.
   */
  static PyObject *
***************
*** 4432,4438 ****
  	 PyDoc_STR("tz -> convert to local time in new timezone tz\n")},
  
- 	{"__getstate__", (PyCFunction)datetime_getstate, METH_NOARGS,
- 	 PyDoc_STR("__getstate__() -> state")},
- 
  	{"__reduce__", (PyCFunction)datetime_reduce,     METH_NOARGS,
  	 PyDoc_STR("__reduce__() -> (cls, state)")},
--- 4427,4430 ----
***************
*** 4530,4573 ****
  	if (PyType_Ready(&PyDateTime_TZInfoType) < 0)
  		return;
- 
- 	/* Make __getnewargs__ a true alias for __getstate__ */
- 	{
- 		PyObject *d, *f;
- 
- 		d = PyDateTime_DateType.tp_dict;
- 		f = PyDict_GetItemString(d, "__getstate__");
- 		if (f != NULL) {
- 			if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- 				return;
- 		}
- 
- 		d = PyDateTime_DateTimeType.tp_dict;
- 		f = PyDict_GetItemString(d, "__getstate__");
- 		if (f != NULL) {
- 			if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- 				return;
- 		}
- 
- 		d = PyDateTime_DeltaType.tp_dict;
- 		f = PyDict_GetItemString(d, "__getstate__");
- 		if (f != NULL) {
- 			if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- 				return;
- 		}
- 
- 		d = PyDateTime_TimeType.tp_dict;
- 		f = PyDict_GetItemString(d, "__getstate__");
- 		if (f != NULL) {
- 			if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- 				return;
- 		}
- 
- 		d = PyDateTime_TZInfoType.tp_dict;
- 		f = PyDict_GetItemString(d, "__getstate__");
- 		if (f != NULL) {
- 			if (PyDict_SetItemString(d, "__getnewargs__", f) < 0)
- 				return;
- 		}
- 	}
  
  	/* timedelta values */
--- 4522,4525 ----