Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit a80649b

Browse files
committed
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.
1 parent c88093a commit a80649b

1 file changed

Lines changed: 21 additions & 111 deletions

File tree

Modules/_tkinter.c

Lines changed: 21 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,12 @@ PERFORMANCE OF THIS SOFTWARE.
3434

3535
/* TCL/TK VERSION INFO:
3636
37-
Unix:
38-
Tcl/Tk 8.0 (even alpha or beta) or 7.6/4.2 are recommended.
39-
Versions 7.5/4.1 are the earliest versions still supported.
40-
Versions 7.4/4.0 or Tk 3.x are no longer supported.
41-
42-
Mac and Windows:
43-
Use Tcl 8.0 if available (even alpha or beta).
44-
The oldest usable version is 4.1p1/7.5p1.
37+
Only Tcl/Tk 8.0 and later are supported. Older versions are not
38+
supported. (Use Python 1.5.2 if you cannot upgrade your Tcl/Tk
39+
libraries.)
40+
*/
4541

46-
XXX Further speed-up ideas, involving Tcl 8.0 features:
42+
/* XXX Further speed-up ideas, involving Tcl 8.0 features:
4743
4844
- In Tcl_Call(), create Tcl objects from the arguments, possibly using
4945
intelligent mappings between Python objects and Tcl objects (e.g. ints,
@@ -80,18 +76,18 @@ PERFORMANCE OF THIS SOFTWARE.
8076

8177
#define TKMAJORMINOR (TK_MAJOR_VERSION*1000 + TK_MINOR_VERSION)
8278

83-
#if TKMAJORMINOR < 4001
84-
#error "Tk 4.0 or 3.x are not supported -- use 4.1 or higher"
79+
#if TKMAJORMINOR < 8000
80+
#error "Tk older than 8.0 not supported"
8581
#endif
8682

87-
#if TKMAJORMINOR >= 8000 && defined(macintosh)
83+
#if defined(macintosh)
8884
/* Sigh, we have to include this to get at the tcl qd pointer */
8985
#include <tkMac.h>
9086
/* And this one we need to clear the menu bar */
9187
#include <Menus.h>
9288
#endif
9389

94-
#if TKMAJORMINOR < 8000 || !defined(MS_WINDOWS)
90+
#if !defined(MS_WINDOWS)
9591
#define HAVE_CREATEFILEHANDLER
9692
#endif
9793

@@ -108,14 +104,6 @@ PERFORMANCE OF THIS SOFTWARE.
108104
#define FHANDLETYPE TCL_UNIX_FD
109105
#endif
110106

111-
#if TKMAJORMINOR < 8000
112-
#define FHANDLE Tcl_File
113-
#define MAKEFHANDLE(fd) Tcl_GetFile((ClientData)(fd), FHANDLETYPE)
114-
#else
115-
#define FHANDLE int
116-
#define MAKEFHANDLE(fd) (fd)
117-
#endif
118-
119107
/* If Tcl can wait for a Unix file descriptor, define the EventHook() routine
120108
which uses this to handle Tcl events while the user is typing commands. */
121109

@@ -219,10 +207,6 @@ static PyThreadState *tcl_tstate = NULL;
219207
#include <Events.h> /* For EventRecord */
220208

221209
typedef int (*TclMacConvertEventPtr) Py_PROTO((EventRecord *eventPtr));
222-
/* They changed the name... */
223-
#if TKMAJORMINOR < 8000
224-
#define Tcl_MacSetEventProc TclMacSetEventProc
225-
#endif
226210
void Tcl_MacSetEventProc Py_PROTO((TclMacConvertEventPtr procPtr));
227211
int TkMacConvertEvent Py_PROTO((EventRecord *eventPtr));
228212

@@ -491,12 +475,8 @@ Tkapp_New(screenName, baseName, className, interactive)
491475

492476
v->interp = Tcl_CreateInterp();
493477

494-
#if TKMAJORMINOR == 8001
495-
TclpInitLibraryPath(baseName);
496-
#endif /* TKMAJORMINOR */
497-
498-
#if defined(macintosh) && TKMAJORMINOR >= 8000
499-
/* This seems to be needed since Tk 8.0 */
478+
#if defined(macintosh)
479+
/* This seems to be needed */
500480
ClearMenuBar();
501481
TkMacInitMenus(v->interp);
502482
#endif
@@ -1440,24 +1420,22 @@ Tkapp_CreateFileHandler(self, args)
14401420
{
14411421
FileHandler_ClientData *data;
14421422
PyObject *file, *func;
1443-
int mask, id;
1444-
FHANDLE tfile;
1423+
int mask, tfile;
14451424

14461425
if (!PyArg_ParseTuple(args, "OiO:createfilehandler", &file, &mask, &func))
14471426
return NULL;
1448-
id = GetFileNo(file);
1449-
if (id < 0)
1427+
tfile = GetFileNo(file);
1428+
if (tfile < 0)
14501429
return NULL;
14511430
if (!PyCallable_Check(func)) {
14521431
PyErr_SetString(PyExc_TypeError, "bad argument list");
14531432
return NULL;
14541433
}
14551434

1456-
data = NewFHCD(func, file, id);
1435+
data = NewFHCD(func, file, tfile);
14571436
if (data == NULL)
14581437
return NULL;
14591438

1460-
tfile = MAKEFHANDLE(id);
14611439
/* Ought to check for null Tcl_File object... */
14621440
ENTER_TCL
14631441
Tcl_CreateFileHandler(tfile, mask, FileHandler, (ClientData) data);
@@ -1473,18 +1451,16 @@ Tkapp_DeleteFileHandler(self, args)
14731451
{
14741452
PyObject *file;
14751453
FileHandler_ClientData *data;
1476-
int id;
1477-
FHANDLE tfile;
1454+
int tfile;
14781455

14791456
if (!PyArg_ParseTuple(args, "O:deletefilehandler", &file))
14801457
return NULL;
1481-
id = GetFileNo(file);
1482-
if (id < 0)
1458+
tfile = GetFileNo(file);
1459+
if (tfile < 0)
14831460
return NULL;
14841461

1485-
DeleteFHCD(id);
1462+
DeleteFHCD(tfile);
14861463

1487-
tfile = MAKEFHANDLE(id);
14881464
/* Ought to check for null Tcl_File object... */
14891465
ENTER_TCL
14901466
Tcl_DeleteFileHandler(tfile);
@@ -1905,15 +1881,15 @@ static int
19051881
EventHook()
19061882
{
19071883
#ifndef MS_WINDOWS
1908-
FHANDLE tfile;
1884+
int tfile;
19091885
#endif
19101886
#ifdef WITH_THREAD
19111887
PyEval_RestoreThread(event_tstate);
19121888
#endif
19131889
stdin_ready = 0;
19141890
errorInCmd = 0;
19151891
#ifndef MS_WINDOWS
1916-
tfile = MAKEFHANDLE(fileno(stdin));
1892+
tfile = fileno(stdin);
19171893
Tcl_CreateFileHandler(tfile, TCL_READABLE, MyFileProc, NULL);
19181894
#endif
19191895
while (!errorInCmd && !stdin_ready) {
@@ -2045,11 +2021,9 @@ init_tkinter()
20452021
Tktt_Type.ob_type = &PyType_Type;
20462022
PyDict_SetItemString(d, "TkttType", (PyObject *)&Tktt_Type);
20472023

2048-
#if TKMAJORMINOR >= 8000
20492024
/* This helps the dynamic loader; in Unicode aware Tcl versions
20502025
it also helps Tcl find its encodings. */
20512026
Tcl_FindExecutable(Py_GetProgramName());
2052-
#endif
20532027

20542028
if (PyErr_Occurred())
20552029
return;
@@ -2058,20 +2032,16 @@ init_tkinter()
20582032
/* This was not a good idea; through <Destroy> bindings,
20592033
Tcl_Finalize() may invoke Python code but at that point the
20602034
interpreter and thread state have already been destroyed! */
2061-
#if TKMAJORMINOR >= 8000
20622035
Py_AtExit(Tcl_Finalize);
20632036
#endif
2064-
#endif
20652037

20662038
#ifdef macintosh
20672039
/*
20682040
** Part of this code is stolen from MacintoshInit in tkMacAppInit.
20692041
** Most of the initializations in that routine (toolbox init calls and
20702042
** such) have already been done for us, so we only need these.
20712043
*/
2072-
#if TKMAJORMINOR >= 8000
20732044
tcl_macQdPtr = &qd;
2074-
#endif
20752045

20762046
Tcl_MacSetEventProc(PyMacConvertEvent);
20772047
#if GENERATINGCFM
@@ -2128,66 +2098,6 @@ PyMacConvertEvent(eventPtr)
21282098
return TkMacConvertEvent(eventPtr);
21292099
}
21302100

2131-
#if defined(USE_GUSI) && TKMAJORMINOR < 8000
2132-
/*
2133-
* For Python we have to override this routine (from TclMacNotify),
2134-
* since we use GUSI for our sockets, not Tcl streams. Hence, we have
2135-
* to use GUSI select to see whether our socket is ready. Note that
2136-
* createfilehandler (above) sets the type to TCL_UNIX_FD for our
2137-
* files and sockets.
2138-
*
2139-
* NOTE: this code was lifted from Tcl 7.6, it may need to be modified
2140-
* for other versions. */
2141-
2142-
int
2143-
Tcl_FileReady(file, mask)
2144-
Tcl_File file; /* File handle for a stream. */
2145-
int mask; /* OR'ed combination of TCL_READABLE,
2146-
* TCL_WRITABLE, and TCL_EXCEPTION:
2147-
* indicates conditions caller cares about. */
2148-
{
2149-
int type;
2150-
int fd;
2151-
2152-
fd = (int) Tcl_GetFileInfo(file, &type);
2153-
2154-
if (type == TCL_MAC_SOCKET) {
2155-
return TclMacSocketReady(file, mask);
2156-
} else if (type == TCL_MAC_FILE) {
2157-
/*
2158-
* Under the Macintosh, files are always ready, so we just
2159-
* return the mask that was passed in.
2160-
*/
2161-
2162-
return mask;
2163-
} else if (type == TCL_UNIX_FD) {
2164-
fd_set readset, writeset, excset;
2165-
struct timeval tv;
2166-
2167-
FD_ZERO(&readset);
2168-
FD_ZERO(&writeset);
2169-
FD_ZERO(&excset);
2170-
2171-
if ( mask & TCL_READABLE ) FD_SET(fd, &readset);
2172-
if ( mask & TCL_WRITABLE ) FD_SET(fd, &writeset);
2173-
if ( mask & TCL_EXCEPTION ) FD_SET(fd, &excset);
2174-
2175-
tv.tv_sec = tv.tv_usec = 0;
2176-
if ( select(fd+1, &readset, &writeset, &excset, &tv) <= 0 )
2177-
return 0;
2178-
2179-
mask = 0;
2180-
if ( FD_ISSET(fd, &readset) ) mask |= TCL_READABLE;
2181-
if ( FD_ISSET(fd, &writeset) ) mask |= TCL_WRITABLE;
2182-
if ( FD_ISSET(fd, &excset) ) mask |= TCL_EXCEPTION;
2183-
2184-
return mask;
2185-
}
2186-
2187-
return 0;
2188-
}
2189-
#endif /* USE_GUSI */
2190-
21912101
#if GENERATINGCFM
21922102

21932103
/*

0 commit comments

Comments
 (0)