[Python-checkins] CVS: python/dist/src/Modules _tkinter.c,1.91,1.92

Guido van Rossum python-dev@python.org
Tue, 28 Mar 2000 15:07:09 -0500 (EST)


Update of /projects/cvsroot/python/dist/src/Modules
In directory eric:/home/guido/hp/mal/py-patched/Modules

Modified Files:
	_tkinter.c 
Log Message:
Patch by Neil Schemenauer to remove support for Tcl/Tk versions before
8.0.  There really is no excuse, and for who really still wants those,
they can go back to Python 1.5.2.


Index: _tkinter.c
===================================================================
RCS file: /projects/cvsroot/python/dist/src/Modules/_tkinter.c,v
retrieving revision 1.91
retrieving revision 1.92
diff -C2 -r1.91 -r1.92
*** _tkinter.c	2000/03/27 21:46:29	1.91
--- _tkinter.c	2000/03/28 20:07:05	1.92
***************
*** 35,48 ****
  /* TCL/TK VERSION INFO:
  
!    Unix:
! 	Tcl/Tk 8.0 (even alpha or beta) or 7.6/4.2 are recommended.
! 	Versions 7.5/4.1 are the earliest versions still supported.
! 	Versions 7.4/4.0 or Tk 3.x are no longer supported.
! 
!    Mac and Windows:
! 	Use Tcl 8.0 if available (even alpha or beta).
! 	The oldest usable version is 4.1p1/7.5p1.
  
!    XXX Further speed-up ideas, involving Tcl 8.0 features:
  
     - In Tcl_Call(), create Tcl objects from the arguments, possibly using
--- 35,44 ----
  /* TCL/TK VERSION INFO:
  
! 	Only Tcl/Tk 8.0 and later are supported.  Older versions are not
! 	supported.  (Use Python 1.5.2 if you cannot upgrade your Tcl/Tk
! 	libraries.)
! */
  
! /* XXX Further speed-up ideas, involving Tcl 8.0 features:
  
     - In Tcl_Call(), create Tcl objects from the arguments, possibly using
***************
*** 81,89 ****
  #define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
  
! #if TKMAJORMINOR < 4001
! 	#error "Tk 4.0 or 3.x are not supported -- use 4.1 or higher"
  #endif
  
! #if TKMAJORMINOR >= 8000 && defined(macintosh)
  /* Sigh, we have to include this to get at the tcl qd pointer */
  #include <tkMac.h>
--- 77,85 ----
  #define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
  
! #if TKMAJORMINOR < 8000
! #error "Tk older than 8.0 not supported"
  #endif
  
! #if defined(macintosh)
  /* Sigh, we have to include this to get at the tcl qd pointer */
  #include <tkMac.h>
***************
*** 92,96 ****
  #endif
  
! #if TKMAJORMINOR < 8000 || !defined(MS_WINDOWS)
  #define HAVE_CREATEFILEHANDLER
  #endif
--- 88,92 ----
  #endif
  
! #if !defined(MS_WINDOWS)
  #define HAVE_CREATEFILEHANDLER
  #endif
***************
*** 109,120 ****
  #endif
  
- #if TKMAJORMINOR < 8000
- #define FHANDLE Tcl_File
- #define MAKEFHANDLE(fd) Tcl_GetFile((ClientData)(fd), FHANDLETYPE)
- #else
- #define FHANDLE int
- #define MAKEFHANDLE(fd) (fd)
- #endif
- 
  /* If Tcl can wait for a Unix file descriptor, define the EventHook() routine
     which uses this to handle Tcl events while the user is typing commands. */
--- 105,108 ----
***************
*** 220,227 ****
  
  typedef int (*TclMacConvertEventPtr) Py_PROTO((EventRecord *eventPtr));
- /* They changed the name... */
- #if TKMAJORMINOR < 8000
- #define Tcl_MacSetEventProc TclMacSetEventProc
- #endif
  void Tcl_MacSetEventProc Py_PROTO((TclMacConvertEventPtr procPtr));
  int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr));
--- 208,211 ----
***************
*** 491,501 ****
  
  	v->interp = Tcl_CreateInterp();
- 
- #if TKMAJORMINOR == 8001
- 	TclpInitLibraryPath(baseName);
- #endif /* TKMAJORMINOR */
  
! #if defined(macintosh) && TKMAJORMINOR >= 8000
! 	/* This seems to be needed since Tk 8.0 */
  	ClearMenuBar();
  	TkMacInitMenus(v->interp);
--- 475,481 ----
  
  	v->interp = Tcl_CreateInterp();
  
! #if defined(macintosh)
! 	/* This seems to be needed */
  	ClearMenuBar();
  	TkMacInitMenus(v->interp);
***************
*** 1441,1451 ****
  	FileHandler_ClientData *data;
  	PyObject *file, *func;
! 	int mask, id;
! 	FHANDLE tfile;
  
  	if (!PyArg_ParseTuple(args, "OiO:createfilehandler", &file, &mask, &func))
  		return NULL;
! 	id = GetFileNo(file);
! 	if (id < 0)
  		return NULL;
  	if (!PyCallable_Check(func)) {
--- 1421,1430 ----
  	FileHandler_ClientData *data;
  	PyObject *file, *func;
! 	int mask, tfile;
  
  	if (!PyArg_ParseTuple(args, "OiO:createfilehandler", &file, &mask, &func))
  		return NULL;
! 	tfile = GetFileNo(file);
! 	if (tfile < 0)
  		return NULL;
  	if (!PyCallable_Check(func)) {
***************
*** 1454,1462 ****
  	}
  
! 	data = NewFHCD(func, file, id);
  	if (data == NULL)
  		return NULL;
  
- 	tfile = MAKEFHANDLE(id);
  	/* Ought to check for null Tcl_File object... */
  	ENTER_TCL
--- 1433,1440 ----
  	}
  
! 	data = NewFHCD(func, file, tfile);
  	if (data == NULL)
  		return NULL;
  
  	/* Ought to check for null Tcl_File object... */
  	ENTER_TCL
***************
*** 1474,1489 ****
  	PyObject *file;
  	FileHandler_ClientData *data;
! 	int id;
! 	FHANDLE tfile;
    
  	if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
  		return NULL;
! 	id = GetFileNo(file);
! 	if (id < 0)
  		return NULL;
  
! 	DeleteFHCD(id);
  
- 	tfile = MAKEFHANDLE(id);
  	/* Ought to check for null Tcl_File object... */
  	ENTER_TCL
--- 1452,1465 ----
  	PyObject *file;
  	FileHandler_ClientData *data;
! 	int tfile;
    
  	if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
  		return NULL;
! 	tfile = GetFileNo(file);
! 	if (tfile < 0)
  		return NULL;
  
! 	DeleteFHCD(tfile);
  
  	/* Ought to check for null Tcl_File object... */
  	ENTER_TCL
***************
*** 1906,1910 ****
  {
  #ifndef MS_WINDOWS
! 	FHANDLE tfile;
  #endif
  #ifdef WITH_THREAD
--- 1882,1886 ----
  {
  #ifndef MS_WINDOWS
! 	int tfile;
  #endif
  #ifdef WITH_THREAD
***************
*** 1914,1918 ****
  	errorInCmd = 0;
  #ifndef MS_WINDOWS
! 	tfile = MAKEFHANDLE(fileno(stdin));
  	Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
  #endif
--- 1890,1894 ----
  	errorInCmd = 0;
  #ifndef MS_WINDOWS
! 	tfile = fileno(stdin);
  	Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
  #endif
***************
*** 2046,2054 ****
  	PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
  
- #if TKMAJORMINOR >= 8000
  	/* This helps the dynamic loader; in Unicode aware Tcl versions
  	   it also helps Tcl find its encodings. */
  	Tcl_FindExecutable(Py_GetProgramName());
- #endif
  
  	if (PyErr_Occurred())
--- 2022,2028 ----
***************
*** 2059,2066 ****
  	   Tcl_Finalize() may invoke Python code but at that point the
  	   interpreter and thread state have already been destroyed! */
- #if TKMAJORMINOR >= 8000
  	Py_AtExit(Tcl_Finalize);
  #endif
- #endif
  
  #ifdef macintosh
--- 2033,2038 ----
***************
*** 2070,2076 ****
  	** such) have already been done for us, so we only need these.
  	*/
- #if TKMAJORMINOR >= 8000
  	tcl_macQdPtr = &qd;
- #endif
  
  	Tcl_MacSetEventProc(PyMacConvertEvent);
--- 2042,2046 ----
***************
*** 2128,2191 ****
  	return TkMacConvertEvent(eventPtr);
  }
- 
- #if defined(USE_GUSI) && TKMAJORMINOR < 8000
- /*
-  * For Python we have to override this routine (from TclMacNotify),
-  * since we use GUSI for our sockets, not Tcl streams. Hence, we have
-  * to use GUSI select to see whether our socket is ready. Note that
-  * createfilehandler (above) sets the type to TCL_UNIX_FD for our
-  * files and sockets.
-  *
-  * NOTE: this code was lifted from Tcl 7.6, it may need to be modified
-  * for other versions.  */
- 
- int
- Tcl_FileReady(file, mask)
-     Tcl_File file;		/* File handle for a stream. */
-     int mask;			/* OR'ed combination of TCL_READABLE,
- 				 * TCL_WRITABLE, and TCL_EXCEPTION:
- 				 * indicates conditions caller cares about. */
- {
-     int type;
-     int fd;
- 
-     fd = (int) Tcl_GetFileInfo(file, &type);
- 
-     if (type == TCL_MAC_SOCKET) {
- 	return TclMacSocketReady(file, mask);
-     } else if (type == TCL_MAC_FILE) {
- 	/*
- 	 * Under the Macintosh, files are always ready, so we just 
- 	 * return the mask that was passed in.
- 	 */
- 
- 	return mask;
-     } else if (type == TCL_UNIX_FD) {
- 	fd_set readset, writeset, excset;
- 	struct timeval tv;
- 	
- 	FD_ZERO(&readset);
- 	FD_ZERO(&writeset);
- 	FD_ZERO(&excset);
- 	
- 	if ( mask & TCL_READABLE ) FD_SET(fd, &readset);
- 	if ( mask & TCL_WRITABLE ) FD_SET(fd, &writeset);
- 	if ( mask & TCL_EXCEPTION ) FD_SET(fd, &excset);
- 	
- 	tv.tv_sec = tv.tv_usec = 0;
- 	if ( select(fd+1, &readset, &writeset, &excset, &tv) <= 0 )
- 		return 0;
- 	
- 	mask = 0;
- 	if ( FD_ISSET(fd, &readset) ) mask |= TCL_READABLE;
- 	if ( FD_ISSET(fd, &writeset) ) mask |= TCL_WRITABLE;
- 	if ( FD_ISSET(fd, &excset) ) mask |= TCL_EXCEPTION;
- 
- 	return mask;
-     }
-     
-     return 0;
- }
- #endif /* USE_GUSI */
  
  #if GENERATINGCFM
--- 2098,2101 ----