mirror of
https://github.com/python/cpython.git
synced 2025-08-30 21:48:47 +00:00
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.
This commit is contained in:
parent
c88093a90f
commit
a80649b357
1 changed files with 21 additions and 111 deletions
|
@ -34,16 +34,12 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
/* TCL/TK VERSION INFO:
|
/* TCL/TK VERSION INFO:
|
||||||
|
|
||||||
Unix:
|
Only Tcl/Tk 8.0 and later are supported. Older versions are not
|
||||||
Tcl/Tk 8.0 (even alpha or beta) or 7.6/4.2 are recommended.
|
supported. (Use Python 1.5.2 if you cannot upgrade your Tcl/Tk
|
||||||
Versions 7.5/4.1 are the earliest versions still supported.
|
libraries.)
|
||||||
Versions 7.4/4.0 or Tk 3.x are no longer supported.
|
*/
|
||||||
|
|
||||||
Mac and Windows:
|
/* XXX Further speed-up ideas, involving Tcl 8.0 features:
|
||||||
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
|
- In Tcl_Call(), create Tcl objects from the arguments, possibly using
|
||||||
intelligent mappings between Python objects and Tcl objects (e.g. ints,
|
intelligent mappings between Python objects and Tcl objects (e.g. ints,
|
||||||
|
@ -80,18 +76,18 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
|
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
|
||||||
|
|
||||||
#if TKMAJORMINOR < 4001
|
#if TKMAJORMINOR < 8000
|
||||||
#error "Tk 4.0 or 3.x are not supported -- use 4.1 or higher"
|
#error "Tk older than 8.0 not supported"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TKMAJORMINOR >= 8000 && defined(macintosh)
|
#if defined(macintosh)
|
||||||
/* Sigh, we have to include this to get at the tcl qd pointer */
|
/* Sigh, we have to include this to get at the tcl qd pointer */
|
||||||
#include <tkMac.h>
|
#include <tkMac.h>
|
||||||
/* And this one we need to clear the menu bar */
|
/* And this one we need to clear the menu bar */
|
||||||
#include <Menus.h>
|
#include <Menus.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if TKMAJORMINOR < 8000 || !defined(MS_WINDOWS)
|
#if !defined(MS_WINDOWS)
|
||||||
#define HAVE_CREATEFILEHANDLER
|
#define HAVE_CREATEFILEHANDLER
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
@ -108,14 +104,6 @@ PERFORMANCE OF THIS SOFTWARE.
|
||||||
#define FHANDLETYPE TCL_UNIX_FD
|
#define FHANDLETYPE TCL_UNIX_FD
|
||||||
#endif
|
#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
|
/* 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. */
|
which uses this to handle Tcl events while the user is typing commands. */
|
||||||
|
|
||||||
|
@ -219,10 +207,6 @@ static PyThreadState *tcl_tstate = NULL;
|
||||||
#include <Events.h> /* For EventRecord */
|
#include <Events.h> /* For EventRecord */
|
||||||
|
|
||||||
typedef int (*TclMacConvertEventPtr) Py_PROTO((EventRecord *eventPtr));
|
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));
|
void Tcl_MacSetEventProc Py_PROTO((TclMacConvertEventPtr procPtr));
|
||||||
int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr));
|
int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr));
|
||||||
|
|
||||||
|
@ -491,12 +475,8 @@ Tkapp_New(screenName, baseName, className, interactive)
|
||||||
|
|
||||||
v->interp = Tcl_CreateInterp();
|
v->interp = Tcl_CreateInterp();
|
||||||
|
|
||||||
#if TKMAJORMINOR == 8001
|
#if defined(macintosh)
|
||||||
TclpInitLibraryPath(baseName);
|
/* This seems to be needed */
|
||||||
#endif /* TKMAJORMINOR */
|
|
||||||
|
|
||||||
#if defined(macintosh) && TKMAJORMINOR >= 8000
|
|
||||||
/* This seems to be needed since Tk 8.0 */
|
|
||||||
ClearMenuBar();
|
ClearMenuBar();
|
||||||
TkMacInitMenus(v->interp);
|
TkMacInitMenus(v->interp);
|
||||||
#endif
|
#endif
|
||||||
|
@ -1440,24 +1420,22 @@ Tkapp_CreateFileHandler(self, args)
|
||||||
{
|
{
|
||||||
FileHandler_ClientData *data;
|
FileHandler_ClientData *data;
|
||||||
PyObject *file, *func;
|
PyObject *file, *func;
|
||||||
int mask, id;
|
int mask, tfile;
|
||||||
FHANDLE tfile;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "OiO:createfilehandler", &file, &mask, &func))
|
if (!PyArg_ParseTuple(args, "OiO:createfilehandler", &file, &mask, &func))
|
||||||
return NULL;
|
return NULL;
|
||||||
id = GetFileNo(file);
|
tfile = GetFileNo(file);
|
||||||
if (id < 0)
|
if (tfile < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
if (!PyCallable_Check(func)) {
|
if (!PyCallable_Check(func)) {
|
||||||
PyErr_SetString(PyExc_TypeError, "bad argument list");
|
PyErr_SetString(PyExc_TypeError, "bad argument list");
|
||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
data = NewFHCD(func, file, id);
|
data = NewFHCD(func, file, tfile);
|
||||||
if (data == NULL)
|
if (data == NULL)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
tfile = MAKEFHANDLE(id);
|
|
||||||
/* Ought to check for null Tcl_File object... */
|
/* Ought to check for null Tcl_File object... */
|
||||||
ENTER_TCL
|
ENTER_TCL
|
||||||
Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data);
|
Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data);
|
||||||
|
@ -1473,18 +1451,16 @@ Tkapp_DeleteFileHandler(self, args)
|
||||||
{
|
{
|
||||||
PyObject *file;
|
PyObject *file;
|
||||||
FileHandler_ClientData *data;
|
FileHandler_ClientData *data;
|
||||||
int id;
|
int tfile;
|
||||||
FHANDLE tfile;
|
|
||||||
|
|
||||||
if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
|
if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
|
||||||
return NULL;
|
return NULL;
|
||||||
id = GetFileNo(file);
|
tfile = GetFileNo(file);
|
||||||
if (id < 0)
|
if (tfile < 0)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
DeleteFHCD(id);
|
DeleteFHCD(tfile);
|
||||||
|
|
||||||
tfile = MAKEFHANDLE(id);
|
|
||||||
/* Ought to check for null Tcl_File object... */
|
/* Ought to check for null Tcl_File object... */
|
||||||
ENTER_TCL
|
ENTER_TCL
|
||||||
Tcl_DeleteFileHandler(tfile);
|
Tcl_DeleteFileHandler(tfile);
|
||||||
|
@ -1905,7 +1881,7 @@ static int
|
||||||
EventHook()
|
EventHook()
|
||||||
{
|
{
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
FHANDLE tfile;
|
int tfile;
|
||||||
#endif
|
#endif
|
||||||
#ifdef WITH_THREAD
|
#ifdef WITH_THREAD
|
||||||
PyEval_RestoreThread(event_tstate);
|
PyEval_RestoreThread(event_tstate);
|
||||||
|
@ -1913,7 +1889,7 @@ EventHook()
|
||||||
stdin_ready = 0;
|
stdin_ready = 0;
|
||||||
errorInCmd = 0;
|
errorInCmd = 0;
|
||||||
#ifndef MS_WINDOWS
|
#ifndef MS_WINDOWS
|
||||||
tfile = MAKEFHANDLE(fileno(stdin));
|
tfile = fileno(stdin);
|
||||||
Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
|
Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
|
||||||
#endif
|
#endif
|
||||||
while (!errorInCmd && !stdin_ready) {
|
while (!errorInCmd && !stdin_ready) {
|
||||||
|
@ -2045,11 +2021,9 @@ init_tkinter()
|
||||||
Tktt_Type.ob_type = &PyType_Type;
|
Tktt_Type.ob_type = &PyType_Type;
|
||||||
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
|
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
|
||||||
|
|
||||||
#if TKMAJORMINOR >= 8000
|
|
||||||
/* This helps the dynamic loader; in Unicode aware Tcl versions
|
/* This helps the dynamic loader; in Unicode aware Tcl versions
|
||||||
it also helps Tcl find its encodings. */
|
it also helps Tcl find its encodings. */
|
||||||
Tcl_FindExecutable(Py_GetProgramName());
|
Tcl_FindExecutable(Py_GetProgramName());
|
||||||
#endif
|
|
||||||
|
|
||||||
if (PyErr_Occurred())
|
if (PyErr_Occurred())
|
||||||
return;
|
return;
|
||||||
|
@ -2058,10 +2032,8 @@ init_tkinter()
|
||||||
/* This was not a good idea; through <Destroy> bindings,
|
/* This was not a good idea; through <Destroy> bindings,
|
||||||
Tcl_Finalize() may invoke Python code but at that point the
|
Tcl_Finalize() may invoke Python code but at that point the
|
||||||
interpreter and thread state have already been destroyed! */
|
interpreter and thread state have already been destroyed! */
|
||||||
#if TKMAJORMINOR >= 8000
|
|
||||||
Py_AtExit(Tcl_Finalize);
|
Py_AtExit(Tcl_Finalize);
|
||||||
#endif
|
#endif
|
||||||
#endif
|
|
||||||
|
|
||||||
#ifdef macintosh
|
#ifdef macintosh
|
||||||
/*
|
/*
|
||||||
|
@ -2069,9 +2041,7 @@ init_tkinter()
|
||||||
** Most of the initializations in that routine (toolbox init calls and
|
** Most of the initializations in that routine (toolbox init calls and
|
||||||
** such) have already been done for us, so we only need these.
|
** such) have already been done for us, so we only need these.
|
||||||
*/
|
*/
|
||||||
#if TKMAJORMINOR >= 8000
|
|
||||||
tcl_macQdPtr = &qd;
|
tcl_macQdPtr = &qd;
|
||||||
#endif
|
|
||||||
|
|
||||||
Tcl_MacSetEventProc(PyMacConvertEvent);
|
Tcl_MacSetEventProc(PyMacConvertEvent);
|
||||||
#if GENERATINGCFM
|
#if GENERATINGCFM
|
||||||
|
@ -2128,66 +2098,6 @@ PyMacConvertEvent(eventPtr)
|
||||||
return TkMacConvertEvent(eventPtr);
|
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
|
#if GENERATINGCFM
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue