[Python-checkins] python/nondist/sandbox/datetime datetime.c,1.63,1.64 obj_timetz.c,1.18,1.19

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Fri, 13 Dec 2002 08:35:37 -0800


Update of /cvsroot/python/python/nondist/sandbox/datetime
In directory sc8-pr-cvs1:/tmp/cvs-serv7549

Modified Files:
	datetime.c obj_timetz.c 
Log Message:
Pausing to rearrange the ever-bloating datetime.c into a more rational
order.  No semantic changes.


Index: datetime.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/datetime.c,v
retrieving revision 1.63
retrieving revision 1.64
diff -C2 -d -r1.63 -r1.64
*** datetime.c	13 Dec 2002 01:13:46 -0000	1.63
--- datetime.c	13 Dec 2002 16:34:58 -0000	1.64
***************
*** 76,81 ****
  static PyTypeObject PyDateTime_TimeTZType;
  
! /*
!  * General calendrical helper functions
   */
  
--- 76,81 ----
  static PyTypeObject PyDateTime_TimeTZType;
  
! /* ---------------------------------------------------------------------------
!  * Math utilities.
   */
  
***************
*** 112,115 ****
--- 112,119 ----
  }
  
+ /* ---------------------------------------------------------------------------
+  * Range checkers.
+  */
+ 
  /* Check that -MAX_DELTA_DAYS <= days <= MAX_DELTA_DAYS.  If so, return 0.
   * If not, raise the given exception and return -1.
***************
*** 131,134 ****
--- 135,142 ----
  }
  
+ /* ---------------------------------------------------------------------------
+  * General calendrical helper functions
+  */
+ 
  /* For each month ordinal in 1..12, the number of days in that month,
   * and the number of days before that month in the same year.  These
***************
*** 306,387 ****
  }
  
  static int
  iso_week1_monday(int year)
  {
! 	int first_day     = ymd_to_ord(year, 1, 1);
  	int first_weekday = (first_day + 6) % 7;
  	int week1_monday  = first_day - first_weekday;
  
! #define THURSDAY 3
! 	if (first_weekday > THURSDAY)
  		week1_monday += 7;
- #undef THURSDAY
  	return week1_monday;
  }
  
! static PyObject *
! format_ctime(PyDateTime_Date *date,
!              int hours, int minutes, int seconds)
! {
! 	static char *DayNames[] = {
! 		"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
! 	};
! 	static char *MonthNames[] = {
! 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
! 		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
! 	};
! 
! 	char buffer[128];
! 	int wday = weekday(GET_YEAR(date), GET_MONTH(date), GET_DAY(date));
! 
! 	PyOS_snprintf(buffer, sizeof(buffer), "%s %s %2d %02d:%02d:%02d %04d",
! 		      DayNames[wday], MonthNames[GET_MONTH(date) - 1],
! 		      GET_DAY(date), hours, minutes, seconds,
! 		      GET_YEAR(date));
! 	return PyString_FromString(buffer);
! }
! 
! /* I sure don't want to reproduce the strftime code from the time module,
!  * so this imports the module and calls it.  Slow!
   */
- static PyObject *
- format_strftime(PyObject *format, PyObject *tuple)
- {
- 	PyObject *time;
- 	PyObject *result;
- 
- 	time = PyImport_ImportModule("time");
- 	if (time == NULL)
- 		return NULL;
- 
-    	result = PyObject_CallMethod(time, "strftime", "OO", format, tuple);
-     	Py_DECREF(time);
-     	return result;
- }
- 
- static char *
- isoformat_date(PyDateTime_Date *dt, char buffer[], int bufflen)
- {
- 	int x;
- 	x = PyOS_snprintf(buffer, bufflen,
- 			  "%04d-%02d-%02d",
- 			  GET_YEAR(dt), GET_MONTH(dt), GET_DAY(dt));
- 	return buffer + x;
- }
- 
- static void
- isoformat_time(PyDateTime_DateTime *dt, char buffer[], int bufflen)
- {
- 	int us = DATE_GET_MICROSECOND(dt);
- 
- 	PyOS_snprintf(buffer, bufflen,
- 		      "%02d:%02d:%02d",	/* 8 characters */
- 		      DATE_GET_HOUR(dt),
- 		      DATE_GET_MINUTE(dt),
- 		      DATE_GET_SECOND(dt));
- 	if (us)
- 		PyOS_snprintf(buffer + 8, bufflen - 8, ".%06d", us);
- }
- 
  
  /* One step of a mixed-radix conversion.  A "hi" unit is equivalent to
--- 314,337 ----
  }
  
+ /* Ordinal of the Monday starting week 1 of the ISO year.  Week 1 is the
+  * first calendar week containing a Thursday.
+  */
  static int
  iso_week1_monday(int year)
  {
! 	int first_day = ymd_to_ord(year, 1, 1);	/* ord of 1/1 */
! 	/* 0 if 1/1 is a Monday, 1 if a Tue, etc. */
  	int first_weekday = (first_day + 6) % 7;
+ 	/* ordinal of closest Monday at or before 1/1 */
  	int week1_monday  = first_day - first_weekday;
  
! 	if (first_weekday > 3)	/* if 1/1 was Fri, Sat, Sun */
  		week1_monday += 7;
  	return week1_monday;
  }
  
! /* ---------------------------------------------------------------------------
!  * Normalization utilities.
   */
  
  /* One step of a mixed-radix conversion.  A "hi" unit is equivalent to
***************
*** 405,408 ****
--- 355,385 ----
  }
  
+ /* Fiddle days (d), seconds (s), and microseconds (us) so that
+  * 	0 <= *s < 24*3600
+  * 	0 <= *us < 1000000
+  * The input values must be such that the internals don't overflow.
+  * The way this routine is used, we don't get close.
+  */
+ static void
+ normalize_d_s_us(long *d, long *s, long *us)
+ {
+ 	if (*us < 0 || *us >= 1000000) {
+ 		normalize_pair(s, us, 1000000);
+ 		/* |s| can't be bigger than about
+ 		 * |original s| + |original us|/1000000 now.
+ 		 */
+ 
+ 	}
+ 	if (*s < 0 || *s >= 24*3600) {
+ 		normalize_pair(d, s, 24*3600);
+ 		/* |d| can't be bigger than about
+ 		 * |original d| +
+ 		 * (|original s| + |original us|/1000000) / (24*3600) now.
+ 		 */
+ 	}
+ 	assert(0 <= *s && *s < 24*3600);
+ 	assert(0 <= *us && *us < 1000000);
+ }
+ 
  /* Fiddle years (y), months (m), and days (d) so that
   * 	1 <= *m <= 12
***************
*** 508,539 ****
  }
  
! /* Fiddle days (d), seconds (s), and microseconds (us) so that
!  * 	0 <= *s < 24*3600
!  * 	0 <= *us < 1000000
!  * The input values must be such that the internals don't overflow.
!  * The way this routine is used, we don't get close.
   */
  static void
! normalize_d_s_us(long *d, long *s, long *us)
  {
! 	if (*us < 0 || *us >= 1000000) {
! 		normalize_pair(s, us, 1000000);
! 		/* |s| can't be bigger than about
! 		 * |original s| + |original us|/1000000 now.
! 		 */
  
  	}
! 	if (*s < 0 || *s >= 24*3600) {
! 		normalize_pair(d, s, 24*3600);
! 		/* |d| can't be bigger than about
! 		 * |original d| +
! 		 * (|original s| + |original us|/1000000) / (24*3600) now.
! 		 */
  	}
! 	assert(0 <= *s && *s < 24*3600);
! 	assert(0 <= *us && *us < 1000000);
  }
  
! /* Wrap functions from the time module.  These aren't directly available
   * from C.  Perhaps they should be.
   */
--- 485,666 ----
  }
  
! /* ---------------------------------------------------------------------------
!  * tzinfo helpers.
!  */
! 
! /* Ensure that p is None or of a tzinfo subclass.  Return 0 if OK; if not
!  * raise TypeError and return -1.
!  */
! static int
! check_tzinfo_subclass(PyObject *p, const char *msg)
! {
! 	if (p == Py_None || PyTZInfo_Check(p))
! 		return 0;
! 	PyErr_Format(PyExc_TypeError,
! 		     "%s must be None or of a tzinfo subclass, "
! 		     "not type '%s'",
! 		     msg, p->ob_type->tp_name);
! 	return -1;
! }
! 
! /* Call tzinfo.utcoffset(tzinfoarg), and extract an integer from the
!  * result.  tzinfo must be an instance of the tzinfo class.  If utcoffset()
!  * returns None, call_utcoffset returns 0 and sets *none to 1.  If uctoffset()
!  & doesn't return a Python int or long, TypeError is raised and this
!  * returns -1.  If utcoffset() returns an int outside the legitimate range
!  * for a UTC offset, ValueError is raised and this returns -1.  Else
!  * *none is set to 0 and the offset is returned.
!  */
! static long
! call_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg, int *none)
! {
! 	PyObject *u;
! 	long result = -1;
! 
! 	assert(tzinfo != NULL);
! 	assert(PyTZInfo_Check(tzinfo));
! 	assert(tzinfoarg != NULL);
! 
! 	*none = 0;
! 	u = PyObject_CallMethod(tzinfo, "utcoffset", "O", tzinfoarg);
! 	if (u == NULL)
! 		return -1;
! 
! 	if (u == Py_None) {
! 		result = 0;
! 		*none = 1;
! 		goto Done;
! 	}
! 
! 	if (PyInt_Check(u))
! 		result = PyInt_AS_LONG(u);
! 	else if (PyLong_Check(u))
! 		result = PyLong_AsLong(u);
! 	else {
! 		PyErr_SetString(PyExc_TypeError,
! 				"utcoffset() must return None or int or long");
! 		goto Done;
! 	}
! 
! 	if (result < -1439 || result > 1439) {
! 		PyErr_Format(PyExc_ValueError,
! 			     "utcoffset() returned %ld; must be in "
! 			     "-1439 .. 1439",
! 			     result);
! 		result = -1;
! 	}
! 
! Done:
! 	Py_DECREF(u);
! 	return result;
! }
! 
! /* ---------------------------------------------------------------------------
!  * String format helpers.
   */
+ 
+ static PyObject *
+ format_ctime(PyDateTime_Date *date,
+              int hours, int minutes, int seconds)
+ {
+ 	static char *DayNames[] = {
+ 		"Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"
+ 	};
+ 	static char *MonthNames[] = {
+ 		"Jan", "Feb", "Mar", "Apr", "May", "Jun",
+ 		"Jul", "Aug", "Sep", "Oct", "Nov", "Dec"
+ 	};
+ 
+ 	char buffer[128];
+ 	int wday = weekday(GET_YEAR(date), GET_MONTH(date), GET_DAY(date));
+ 
+ 	PyOS_snprintf(buffer, sizeof(buffer), "%s %s %2d %02d:%02d:%02d %04d",
+ 		      DayNames[wday], MonthNames[GET_MONTH(date) - 1],
+ 		      GET_DAY(date), hours, minutes, seconds,
+ 		      GET_YEAR(date));
+ 	return PyString_FromString(buffer);
+ }
+ 
+ /* I sure don't want to reproduce the strftime code from the time module,
+  * so this imports the module and calls it.
+  */
+ static PyObject *
+ format_strftime(PyObject *format, PyObject *tuple)
+ {
+ 	PyObject *time;
+ 	PyObject *result;
+ 
+ 	time = PyImport_ImportModule("time");
+ 	if (time == NULL)
+ 		return NULL;
+ 
+    	result = PyObject_CallMethod(time, "strftime", "OO", format, tuple);
+     	Py_DECREF(time);
+     	return result;
+ }
+ 
+ static char *
+ isoformat_date(PyDateTime_Date *dt, char buffer[], int bufflen)
+ {
+ 	int x;
+ 	x = PyOS_snprintf(buffer, bufflen,
+ 			  "%04d-%02d-%02d",
+ 			  GET_YEAR(dt), GET_MONTH(dt), GET_DAY(dt));
+ 	return buffer + x;
+ }
+ 
  static void
! isoformat_time(PyDateTime_DateTime *dt, char buffer[], int bufflen)
  {
! 	int us = DATE_GET_MICROSECOND(dt);
! 
! 	PyOS_snprintf(buffer, bufflen,
! 		      "%02d:%02d:%02d",	/* 8 characters */
! 		      DATE_GET_HOUR(dt),
! 		      DATE_GET_MINUTE(dt),
! 		      DATE_GET_SECOND(dt));
! 	if (us)
! 		PyOS_snprintf(buffer + 8, bufflen - 8, ".%06d", us);
! }
! 
! /* Add an hours & minutes UTC offset string to buf.  buf has no more than
!  * buflen bytes remaining.  The UTC offset is gotten by calling
!  * tzinfo.uctoffset(tzinfoarg).  If that returns None, \0 is stored into
!  * *buf, and that's all.  Else the returned value is checked for sanity (an
!  * integer in range), and if that's OK it's converted to an hours & minutes
!  * string of the form
!  *   sign HH sep MM
!  * Returns 0 if everything is OK.  If the return value from utcoffset() is
!  * bogus, an appropriate exception is set and -1 is returned.
!  */
! static int
! format_utcoffset(char *buf, int buflen, const char *sep,
! 		PyObject *tzinfo, PyObject *tzinfoarg)
! {
! 	long offset;
! 	long hours;
! 	long minutes;
! 	char sign;
! 	int none;
  
+ 	offset = call_utcoffset(tzinfo, tzinfoarg, &none);
+ 	if (offset == -1 && PyErr_Occurred())
+ 		return -1;
+ 	if (none) {
+ 		*buf = '\0';
+ 		return 0;
  	}
! 	sign = '+';
! 	if (offset < 0) {
! 		sign = '-';
! 		offset = - offset;
  	}
! 	hours = divmod(offset, 60, &minutes);
! 	PyOS_snprintf(buf, buflen, "%c%02d%s%02d", sign, hours, sep, minutes);
! 	return 0;
  }
  
! /* ---------------------------------------------------------------------------
!  * Wrap functions from the time module.  These aren't directly available
   * from C.  Perhaps they should be.
   */
***************
*** 574,591 ****
  }
  
! /* Ensure that p is None or of a tzinfo subclass.  Return 0 if OK; if not
!  * raise TypeError and return -1.
   */
- static int
- check_tzinfo_subclass(PyObject *p, const char *msg)
- {
- 	if (p == Py_None || PyTZInfo_Check(p))
- 		return 0;
- 	PyErr_Format(PyExc_TypeError,
- 		     "%s must be None or of a tzinfo subclass, "
- 		     "not type '%s'",
- 		     msg, p->ob_type->tp_name);
- 	return -1;
- }
  
  /* For obscure reasons, we need to use tp_richcompare instead of tp_compare.
--- 701,707 ----
  }
  
! /* ---------------------------------------------------------------------------
!  * Miscellaneous helpers.
   */
  
  /* For obscure reasons, we need to use tp_richcompare instead of tp_compare.
***************
*** 615,618 ****
--- 731,740 ----
  }
  
+ /* ---------------------------------------------------------------------------
+  * Helpers for setting object fields.  These work on pointers to the
+  * appropriate base class.
+  */
+ 
+ /* For date, datetime and datetimetz. */
  static void
  set_date_fields(PyDateTime_Date *self, int y, int m, int d)
***************
*** 624,627 ****
--- 746,750 ----
  }
  
+ /* For datetime and datetimetz. */
  static void
  set_datetime_time_fields(PyDateTime_Date *self, int h, int m, int s, int us)
***************
*** 633,636 ****
--- 756,774 ----
  }
  
+ /* For time and timetz. */
+ static void
+ set_time_fields(PyDateTime_Time *self, int h, int m, int s, int us)
+ {
+ 	self->hashcode = -1;
+ 	TIME_SET_HOUR(self, h);
+ 	TIME_SET_MINUTE(self, m);
+ 	TIME_SET_SECOND(self, s);
+ 	TIME_SET_MICROSECOND(self, us);
+ }
+ 
+ /* ---------------------------------------------------------------------------
+  * Create various objects, mostly without range checking.
+  */
+ 
  /* Create a date instance with no range checking. */
  static PyObject *
***************
*** 679,692 ****
  }
  
- static void
- set_time_fields(PyDateTime_Time *self, int h, int m, int s, int us)
- {
- 	self->hashcode = -1;
- 	TIME_SET_HOUR(self, h);
- 	TIME_SET_MINUTE(self, m);
- 	TIME_SET_SECOND(self, s);
- 	TIME_SET_MICROSECOND(self, us);
- }
- 
  /* Create a time instance with no range checking. */
  static PyObject *
--- 817,820 ----
***************
*** 746,841 ****
  }
  
- /* Helpers for dealing with calling tzinfo methods. */
- 
- /* Call tzinfo.utcoffset(tzinfoarg), and extract an integer from the
-  * result.  tzinfo must be an instance of the tzinfo class.  If utcoffset()
-  * returns None, get_utcoffset returns 0 and sets *none to 1.  If uctoffset()
-  & doesn't return a Python int or long, TypeError is raised and this
-  * returns -1.  If utcoffset() returns an int outside the legitimate range
-  * for a UTC offset, ValueError is raised and this returns -1.  Else
-  * *none is set to 0 and the offset is returned.
-  */
- static long
- get_utcoffset(PyObject *tzinfo, PyObject *tzinfoarg, int *none)
- {
- 	PyObject *u;
- 	long result = -1;
- 
- 	assert(tzinfo != NULL);
- 	assert(PyTZInfo_Check(tzinfo));
- 	assert(tzinfoarg != NULL);
- 
- 	*none = 0;
- 	u = PyObject_CallMethod(tzinfo, "utcoffset", "O", tzinfoarg);
- 	if (u == NULL)
- 		return -1;
- 
- 	if (u == Py_None) {
- 		result = 0;
- 		*none = 1;
- 		goto Done;
- 	}
- 
- 	if (PyInt_Check(u))
- 		result = PyInt_AS_LONG(u);
- 	else if (PyLong_Check(u))
- 		result = PyLong_AsLong(u);
- 	else {
- 		PyErr_SetString(PyExc_TypeError,
- 				"utcoffset() must return None or int or long");
- 		goto Done;
- 	}
- 
- 	if (result < -1439 || result > 1439) {
- 		PyErr_Format(PyExc_ValueError,
- 			     "utcoffset() returned %ld; must be in "
- 			     "-1439 .. 1439",
- 			     result);
- 		result = -1;
- 	}
- 
- Done:
- 	Py_DECREF(u);
- 	return result;
- }
- 
- /* Add an hours & minutes UTC offset string to buf.  buf has no more than
-  * buflen bytes remaining.  The UTC offset is gotten by calling
-  * tzinfo.uctoffset(tzinfoarg).  If that returns None, \0 is stored into
-  * *buf, and that's all.  Else the returned value is checked for sanity (an
-  * integer in range), and if that's OK it's converted to an hours & minutes
-  * string of the form
-  *   sign HH sep MM
-  * Returns 0 if everything is OK.  If the return value from utcoffset() is
-  * bogus, an appropriate exception is set and -1 is returned.
-  */
- static int
- format_utcoffset(char *buf, int buflen, const char *sep,
- 		PyObject *tzinfo, PyObject *tzinfoarg)
- {
- 	long offset;
- 	long hours;
- 	long minutes;
- 	char sign;
- 	int none;
- 
- 	offset = get_utcoffset(tzinfo, tzinfoarg, &none);
- 	if (offset == -1 && PyErr_Occurred())
- 		return -1;
- 	if (none) {
- 		*buf = '\0';
- 		return 0;
- 	}
- 	sign = '+';
- 	if (offset < 0) {
- 		sign = '-';
- 		offset = - offset;
- 	}
- 	hours = divmod(offset, 60, &minutes);
- 	PyOS_snprintf(buf, buflen, "%c%02d%s%02d", sign, hours, sep, minutes);
- 	return 0;
- }
  
! /*
   * Cached Python objects; these are set by the module init function.
   */
--- 874,879 ----
  }
  
  
! /* ---------------------------------------------------------------------------
   * Cached Python objects; these are set by the module init function.
   */
***************
*** 859,862 ****
--- 897,904 ----
  static PyObject *timetz_unpickler_object = NULL;
  
+ /* ---------------------------------------------------------------------------
+  * Class implementations.
+  */
+ 
  #include "obj_delta.c"
  #include "obj_date.c"
***************
*** 867,870 ****
--- 909,915 ----
  #include "obj_datetimetz.c"
  
+ /* ---------------------------------------------------------------------------
+  * Module methods and initialization.
+  */
  
  static PyMethodDef module_methods[] = {
***************
*** 922,926 ****
  	/* Pickling support, via registering functions with copy_reg. */
  	{
- 		PyObject *temp;
  		PyObject *pickler;
  		PyObject *copyreg = PyImport_ImportModule("copy_reg");
--- 967,970 ----
***************
*** 933,942 ****
  						"_date_unpickler");
  		if (date_unpickler_object == NULL) return;
! 	    	temp = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				   &PyDateTime_DateType,
! 	    				   pickler,
! 		                           date_unpickler_object);
! 		if (temp == NULL) return;
! 		Py_DECREF(temp);
  		Py_DECREF(pickler);
  
--- 977,986 ----
  						"_date_unpickler");
  		if (date_unpickler_object == NULL) return;
! 	    	x = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				&PyDateTime_DateType,
! 	    				pickler,
! 		                    	date_unpickler_object);
! 		if (x == NULL) return;
! 		Py_DECREF(x);
  		Py_DECREF(pickler);
  
***************
*** 946,955 ****
  						"_datetime_unpickler");
  		if (datetime_unpickler_object == NULL) return;
! 	    	temp = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				   &PyDateTime_DateTimeType,
! 	    				   pickler,
! 		                           datetime_unpickler_object);
! 		if (temp == NULL) return;
! 		Py_DECREF(temp);
  		Py_DECREF(pickler);
  
--- 990,999 ----
  						"_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);
  
***************
*** 959,968 ****
  						"_time_unpickler");
  		if (time_unpickler_object == NULL) return;
! 	    	temp = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				   &PyDateTime_TimeType,
! 	    				   pickler,
! 		                           time_unpickler_object);
! 		if (temp == NULL) return;
! 		Py_DECREF(temp);
  		Py_DECREF(pickler);
  
--- 1003,1012 ----
  						"_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);
  
***************
*** 972,981 ****
  						"_timetz_unpickler");
  		if (timetz_unpickler_object == NULL) return;
! 	    	temp = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				   &PyDateTime_TimeTZType,
! 	    				   pickler,
! 		                           timetz_unpickler_object);
! 		if (temp == NULL) return;
! 		Py_DECREF(temp);
  		Py_DECREF(pickler);
  
--- 1016,1025 ----
  						"_timetz_unpickler");
  		if (timetz_unpickler_object == NULL) return;
! 	    	x = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				&PyDateTime_TimeTZType,
! 	    				pickler,
! 		                	timetz_unpickler_object);
! 		if (x == NULL) return;
! 		Py_DECREF(x);
  		Py_DECREF(pickler);
  
***************
*** 985,994 ****
  							"_tzinfo_unpickler");
  		if (tzinfo_unpickler_object == NULL) return;
! 	    	temp = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				   &PyDateTime_TZInfoType,
! 	    				   pickler,
! 		                           tzinfo_unpickler_object);
! 		if (temp == NULL) return;
! 		Py_DECREF(temp);
  		Py_DECREF(pickler);
  
--- 1029,1038 ----
  							"_tzinfo_unpickler");
  		if (tzinfo_unpickler_object == NULL) return;
! 	    	x = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				&PyDateTime_TZInfoType,
! 	    				pickler,
! 		        		tzinfo_unpickler_object);
! 		if (x== NULL) return;
! 		Py_DECREF(x);
  		Py_DECREF(pickler);
  
***************
*** 998,1007 ****
  						 "_datetimetz_unpickler");
  		if (datetimetz_unpickler_object == NULL) return;
! 	    	temp = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				   &PyDateTime_DateTimeTZType,
! 	    				   pickler,
! 		                           datetimetz_unpickler_object);
! 		if (temp == NULL) return;
! 		Py_DECREF(temp);
  		Py_DECREF(pickler);
  
--- 1042,1051 ----
  						 "_datetimetz_unpickler");
  		if (datetimetz_unpickler_object == NULL) return;
! 	    	x = PyObject_CallMethod(copyreg, "pickle", "OOO",
! 	    				&PyDateTime_DateTimeTZType,
! 	    				pickler,
! 		                	datetimetz_unpickler_object);
! 		if (x== NULL) return;
! 		Py_DECREF(x);
  		Py_DECREF(pickler);
  

Index: obj_timetz.c
===================================================================
RCS file: /cvsroot/python/python/nondist/sandbox/datetime/obj_timetz.c,v
retrieving revision 1.18
retrieving revision 1.19
diff -C2 -d -r1.18 -r1.19
*** obj_timetz.c	12 Dec 2002 23:04:14 -0000	1.18
--- obj_timetz.c	13 Dec 2002 16:35:09 -0000	1.19
***************
*** 202,208 ****
  	}
  	else {
! 		self_offset = get_utcoffset(self_tzinfo,
! 					    (PyObject *)self,
! 					    &self_none);
  		if (self_offset == -1 && PyErr_Occurred())
  			return NULL;
--- 202,208 ----
  	}
  	else {
! 		self_offset = call_utcoffset(self_tzinfo,
! 					     (PyObject *)self,
! 					     &self_none);
  		if (self_offset == -1 && PyErr_Occurred())
  			return NULL;
***************
*** 214,220 ****
  	}
  	else {
! 		other_offset = get_utcoffset(other_tzinfo,
! 					     (PyObject *)other,
! 					     &other_none);
  		if (other_offset == -1 && PyErr_Occurred())
  			return NULL;
--- 214,220 ----
  	}
  	else {
! 		other_offset = call_utcoffset(other_tzinfo,
! 					      (PyObject *)other,
! 					      &other_none);
  		if (other_offset == -1 && PyErr_Occurred())
  			return NULL;
***************
*** 264,268 ****
  		goto Done;
  
! 	offset = get_utcoffset(self->tzinfo, (PyObject *)self, &none);
  	if (offset == -1 && PyErr_Occurred()) {
  		self->hashcode = -1;
--- 264,268 ----
  		goto Done;
  
! 	offset = call_utcoffset(self->tzinfo, (PyObject *)self, &none);
  	if (offset == -1 && PyErr_Occurred()) {
  		self->hashcode = -1;
***************
*** 305,309 ****
  	offset = 0;
  	if (self->tzinfo != Py_None) {
! 		offset = get_utcoffset(self->tzinfo, (PyObject *)self, &none);
  		if (offset == -1 && PyErr_Occurred())
  			return -1;
--- 305,309 ----
  	offset = 0;
  	if (self->tzinfo != Py_None) {
! 		offset = call_utcoffset(self->tzinfo, (PyObject *)self, &none);
  		if (offset == -1 && PyErr_Occurred())
  			return -1;