[Python-checkins] python/dist/src/Modules timemodule.c,2.133,2.134

tim_one@users.sourceforge.net tim_one@users.sourceforge.net
Sat, 18 Jan 2003 20:55:01 -0800


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

Modified Files:
	timemodule.c 
Log Message:
Windows flavor of floatsleep():  folded long lines, introduced a temp
var for clarity.


Index: timemodule.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/timemodule.c,v
retrieving revision 2.133
retrieving revision 2.134
diff -C2 -d -r2.133 -r2.134
*** timemodule.c	17 Jan 2003 20:08:54 -0000	2.133
--- timemodule.c	19 Jan 2003 04:54:58 -0000	2.134
***************
*** 456,460 ****
      PyObject *strptime_module = PyImport_ImportModule("_strptime");
  
!     if (!strptime_module) 
          return NULL;
      return PyObject_CallMethod(strptime_module, "strptime", "O", args);
--- 456,460 ----
      PyObject *strptime_module = PyImport_ImportModule("_strptime");
  
!     if (!strptime_module)
          return NULL;
      return PyObject_CallMethod(strptime_module, "strptime", "O", args);
***************
*** 812,835 ****
  	{
  		double millisecs = secs * 1000.0;
  		if (millisecs > (double)ULONG_MAX) {
! 			PyErr_SetString(PyExc_OverflowError, "sleep length is too large");
  			return -1;
  		}
  		Py_BEGIN_ALLOW_THREADS
! 		/* allow sleep(0) to maintain win32 semantics, and as decreed by
! 		   Guido, only the main thread can be interrupted. */
! 		if ((unsigned long)millisecs==0 || main_thread != PyThread_get_thread_ident())
! 			Sleep((unsigned long)millisecs);
  		else {
  			DWORD rc;
  			ResetEvent(hInterruptEvent);
! 			rc = WaitForSingleObject(hInterruptEvent, (unsigned long)millisecs);
! 			if (rc==WAIT_OBJECT_0) {
! 				/* yield to make sure real Python signal handler called */
  				Sleep(1);
  				Py_BLOCK_THREADS
- 				/* PyErr_SetFromErrno() does the "right thing" wrt signals
- 				   if errno=EINTR
- 				*/
  				errno = EINTR;
  				PyErr_SetFromErrno(PyExc_IOError);
--- 812,840 ----
  	{
  		double millisecs = secs * 1000.0;
+ 		unsigned long ul_millis;
+ 
  		if (millisecs > (double)ULONG_MAX) {
! 			PyErr_SetString(PyExc_OverflowError,
! 					"sleep length is too large");
  			return -1;
  		}
  		Py_BEGIN_ALLOW_THREADS
! 		/* Allow sleep(0) to maintain win32 semantics, and as decreed
! 		 * by Guido, only the main thread can be interrupted.
! 		 */
! 		ul_millis = (unsigned long)millisecs;
! 		if (ul_millis == 0 ||
! 		    main_thread != PyThread_get_thread_ident())
! 			Sleep(ul_millis);
  		else {
  			DWORD rc;
  			ResetEvent(hInterruptEvent);
! 			rc = WaitForSingleObject(hInterruptEvent, ul_millis);
! 			if (rc == WAIT_OBJECT_0) {
! 				/* Yield to make sure real Python signal
! 				 * handler called.
! 				 */
  				Sleep(1);
  				Py_BLOCK_THREADS
  				errno = EINTR;
  				PyErr_SetFromErrno(PyExc_IOError);