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

Skip to content

Commit 71b49dd

Browse files
Issue #16840. Turn off bignum support in tkinter with with Tcl earlier than 8.5.8
(tclTomMath.h was broken) and non-final Tcl 8.6. Removed TK_VERSION_HEX.
2 parents aec0509 + 3af7a38 commit 71b49dd

3 files changed

Lines changed: 15 additions & 12 deletions

File tree

Lib/test/test_tcl.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -131,7 +131,9 @@ def testUnsetVarException(self):
131131

132132
def get_integers(self):
133133
integers = (0, 1, -1, 2**31-1, -2**31, 2**31, -2**31-1, 2**63-1, -2**63)
134-
if tcl_version >= (8, 5): # bignum was added in Tcl 8.5
134+
# bignum was added in Tcl 8.5, but its support is able only since 8.5.8
135+
if (get_tk_patchlevel() >= (8, 6, 0, 'final') or
136+
(8, 5, 8) <= get_tk_patchlevel() < (8, 6)):
135137
integers += (2**63, -2**63-1, 2**1000, -2**1000)
136138
return integers
137139

Modules/_tkinter.c

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,11 +52,12 @@ Copyright (C) 1994 Steen Lumholt.
5252

5353
#include "tkinter.h"
5454

55-
#if TK_VERSION_HEX < 0x08040002
55+
#if TK_HEX_VERSION < 0x08040200
5656
#error "Tk older than 8.4 not supported"
5757
#endif
5858

59-
#if TK_VERSION_HEX >= 0x08050002
59+
#if TK_HEX_VERSION >= 0x08050208 && TK_HEX_VERSION < 0x08060000 || \
60+
TK_HEX_VERSION >= 0x08060200
6061
#define HAVE_LIBTOMMAMTH
6162
#include <tclTomMath.h>
6263
#endif
@@ -1227,7 +1228,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value)
12271228
Tcl_GetCharLength(value));
12281229
}
12291230

1230-
#if TK_VERSION_HEX >= 0x08050000
1231+
#if TK_HEX_VERSION >= 0x08050000
12311232
if (app->BooleanType == NULL &&
12321233
strcmp(value->typePtr->name, "booleanString") == 0) {
12331234
/* booleanString type is not registered in Tcl */

Modules/tkinter.h

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,24 +4,24 @@
44
/* This header is used to share some macros between _tkinter.c and
55
* tkappinit.c.
66
* Be sure to include tk.h before including this header so
7-
* TK_VERSION_HEX is properly defined. */
7+
* TK_HEX_VERSION is properly defined. */
88

99
/* TK_RELEASE_LEVEL is always one of the following:
10-
* TCL_ALPHA_RELEASE 0
10+
* TCL_ALPHA_RELEASE 0
1111
* TCL_BETA_RELEASE 1
1212
* TCL_FINAL_RELEASE 2
1313
*/
14-
#define TK_VERSION_HEX ((TK_MAJOR_VERSION << 24) | \
15-
(TK_MINOR_VERSION << 16) | \
16-
(TK_RELEASE_SERIAL << 8) | \
17-
(TK_RELEASE_LEVEL << 0))
14+
#define TK_HEX_VERSION ((TK_MAJOR_VERSION << 24) | \
15+
(TK_MINOR_VERSION << 16) | \
16+
(TK_RELEASE_LEVEL << 8) | \
17+
(TK_RELEASE_SERIAL << 0))
1818

1919
/* Protect Tk 8.4.13 and older from a deadlock that happens when trying
2020
* to load tk after a failed attempt. */
21-
#if TK_VERSION_HEX < 0x08040e02
21+
#if TK_HEX_VERSION < 0x0804020e
2222
#define TKINTER_PROTECT_LOADTK
2323
#define TKINTER_LOADTK_ERRMSG \
24-
"Calling Tk_Init again after a previous call failed might deadlock"
24+
"Calling Tk_Init again after a previous call failed might deadlock"
2525
#endif
2626

2727
#endif /* !TKINTER_H */

0 commit comments

Comments
 (0)