[Python-bugs-list] time.daylight error (PR#104)

guido@CNRI.Reston.VA.US guido@CNRI.Reston.VA.US
Tue, 12 Oct 1999 23:17:52 -0400 (EDT)


> However, the same thing fails in 1.5.2 on the same machine:
> 
> $ /usr/local/bin/python
> Python 1.5.2 (#1, Oct 13 1999, 10:18:22)  [GCC 2.7.2.3] on linux2
> Copyright 1991-1995 Stichting Mathematisch Centrum, Amsterdam
> >>> import time
> >>> time.daylight
> Traceback (innermost last):
>   File "<stdin>", line 1, in ?
> AttributeError: daylight
> >>>

I believe this is a bug in the way timemodule.c detects different
GLIBC versions.  It has been fixed in our CVS version; here is the
patch for you:

Index: timemodule.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.74
retrieving revision 2.75
diff -c -r2.74 -r2.75
*** timemodule.c	1999/04/05 21:54:14	2.74
--- timemodule.c	1999/04/23 20:59:05	2.75
***************
*** 616,622 ****
  	/* Squirrel away the module's dictionary for the y2k check */
  	Py_INCREF(d);
  	moddict = d;
! #if defined(HAVE_TZNAME) && !defined(__GNU_LIBRARY__)
  	tzset();
  #ifdef PYOS_OS2
  	ins(d, "timezone", PyInt_FromLong((long)_timezone));
--- 616,622 ----
  	/* Squirrel away the module's dictionary for the y2k check */
  	Py_INCREF(d);
  	moddict = d;
! #if defined(HAVE_TZNAME) && !defined(__GLIBC__)
  	tzset();
  #ifdef PYOS_OS2
  	ins(d, "timezone", PyInt_FromLong((long)_timezone));
***************
*** 634,640 ****
  #endif
  	ins(d, "daylight", PyInt_FromLong((long)daylight));
  	ins(d, "tzname", Py_BuildValue("(zz)", tzname[0], tzname[1]));
! #else /* !HAVE_TZNAME || __GNU_LIBRARY__ */
  #ifdef HAVE_TM_ZONE
  	{
  #define YEAR ((time_t)((365 * 24 + 6) * 3600))
--- 634,640 ----
  #endif
  	ins(d, "daylight", PyInt_FromLong((long)daylight));
  	ins(d, "tzname", Py_BuildValue("(zz)", tzname[0], tzname[1]));
! #else /* !HAVE_TZNAME || __GLIBC__ */
  #ifdef HAVE_TM_ZONE
  	{
  #define YEAR ((time_t)((365 * 24 + 6) * 3600))
***************
*** 683,689 ****
  	ins(d, "tzname", Py_BuildValue("(zz)", "", ""));
  #endif /* macintosh */
  #endif /* HAVE_TM_ZONE */
! #endif /* !HAVE_TZNAME || __GNU_LIBRARY__ */
  	if (PyErr_Occurred())
  		Py_FatalError("Can't initialize time module");
  }
--- 683,689 ----
  	ins(d, "tzname", Py_BuildValue("(zz)", "", ""));
  #endif /* macintosh */
  #endif /* HAVE_TM_ZONE */
! #endif /* !HAVE_TZNAME || __GLIBC__ */
  	if (PyErr_Occurred())
  		Py_FatalError("Can't initialize time module");
  }

--Guido van Rossum (home page: http://www.python.org/~guido/)