[Python-checkins] python/dist/src/Modules _tkinter.c,1.149,1.150

loewis@users.sourceforge.net loewis@users.sourceforge.net
Mon, 03 Mar 2003 02:40:16 -0800


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

Modified Files:
	_tkinter.c 
Log Message:
Don't crash on _tkinter.createfilehandler in non-threaded Tcl;
disable this function in threaded Tcl. Likewise for creaetetimerhandler.
Fixes #692416.


Index: _tkinter.c
===================================================================
RCS file: /cvsroot/python/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.149
retrieving revision 1.150
diff -C2 -d -r1.149 -r1.150
*** _tkinter.c	11 Feb 2003 23:05:40 -0000	1.149
--- _tkinter.c	3 Mar 2003 10:40:01 -0000	1.150
***************
*** 2203,2207 ****
  			      &file, &mask, &func))
  		return NULL;
! 	CHECK_TCL_APPARTMENT;
  	tfile = PyObject_AsFileDescriptor(file);
  	if (tfile < 0)
--- 2203,2219 ----
  			      &file, &mask, &func))
  		return NULL;
! 
! 	if (!self && !tcl_lock) {
! 		/* We don't have the Tcl lock since Tcl is threaded. */
! 		PyErr_SetString(PyExc_RuntimeError,
! 				"_tkinter.createfilehandler not supported "
! 				"for threaded Tcl");
! 		return NULL;
! 	}
! 
! 	if (self) {
! 		CHECK_TCL_APPARTMENT;
! 	}
! 
  	tfile = PyObject_AsFileDescriptor(file);
  	if (tfile < 0)
***************
*** 2397,2400 ****
--- 2409,2425 ----
  		return NULL;
  	}
+ 
+ 	if (!self && !tcl_lock) {
+ 		/* We don't have the Tcl lock since Tcl is threaded. */
+ 		PyErr_SetString(PyExc_RuntimeError,
+ 				"_tkinter.createtimerhandler not supported "
+ 				"for threaded Tcl");
+ 		return NULL;
+ 	}
+ 
+ 	if (self) {
+ 		CHECK_TCL_APPARTMENT;
+ 	}
+ 
  	v = Tktt_New(func);
  	v->token = Tcl_CreateTimerHandler(milliseconds, TimerHandler,