From 3af7a38c616869b1d195add43b43e8af118e6a31 Mon Sep 17 00:00:00 2001 From: Serhiy Storchaka Date: Wed, 22 Apr 2015 10:53:08 +0300 Subject: [PATCH] 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. --- Lib/test/test_tcl.py | 4 +++- Modules/_tkinter.c | 7 ++++--- Modules/tkinter.h | 22 +++++++++++++++------- 3 files changed, 22 insertions(+), 11 deletions(-) diff --git a/Lib/test/test_tcl.py b/Lib/test/test_tcl.py index 9dae4760141..66e9d49dfea 100644 --- a/Lib/test/test_tcl.py +++ b/Lib/test/test_tcl.py @@ -133,7 +133,9 @@ def get_integers(self): integers = (0, 1, -1, 2**31-1, -2**31) if tcl_version >= (8, 4): # wideInt was added in Tcl 8.4 integers += (2**31, -2**31-1, 2**63-1, -2**63) - if tcl_version >= (8, 5): # bignum was added in Tcl 8.5 + # bignum was added in Tcl 8.5, but its support is able only since 8.5.8 + if (get_tk_patchlevel() >= (8, 6, 0, 'final') or + (8, 5, 8) <= get_tk_patchlevel() < (8, 6)): integers += (2**63, -2**63-1, 2**1000, -2**1000) return integers diff --git a/Modules/_tkinter.c b/Modules/_tkinter.c index 491a8fe283a..52025bb16f6 100644 --- a/Modules/_tkinter.c +++ b/Modules/_tkinter.c @@ -65,11 +65,12 @@ Copyright (C) 1994 Steen Lumholt. #define CONST #endif -#if TK_VERSION_HEX < 0x08030102 +#if TK_HEX_VERSION < 0x08030201 #error "Tk older than 8.3.1 not supported" #endif -#if TK_VERSION_HEX >= 0x08050002 +#if TK_HEX_VERSION >= 0x08050208 && TK_HEX_VERSION < 0x08060000 || \ + TK_HEX_VERSION >= 0x08060200 #define HAVE_LIBTOMMAMTH #include #endif @@ -1214,7 +1215,7 @@ FromObj(PyObject* tkapp, Tcl_Obj *value) Tcl_GetCharLength(value)); } -#if TK_VERSION_HEX >= 0x08050000 +#if TK_HEX_VERSION >= 0x08050000 if (app->BooleanType == NULL && strcmp(value->typePtr->name, "booleanString") == 0) { /* booleanString type is not registered in Tcl */ diff --git a/Modules/tkinter.h b/Modules/tkinter.h index f7e50cde0c7..3c55676c0f0 100644 --- a/Modules/tkinter.h +++ b/Modules/tkinter.h @@ -4,24 +4,32 @@ /* This header is used to share some macros between _tkinter.c and * tkappinit.c. * Be sure to include tk.h before including this header so - * TK_VERSION_HEX is properly defined. */ + * TK_HEX_VERSION is properly defined. */ /* TK_RELEASE_LEVEL is always one of the following: - * TCL_ALPHA_RELEASE 0 + * TCL_ALPHA_RELEASE 0 * TCL_BETA_RELEASE 1 * TCL_FINAL_RELEASE 2 */ +#define TK_HEX_VERSION ((TK_MAJOR_VERSION << 24) | \ + (TK_MINOR_VERSION << 16) | \ + (TK_RELEASE_LEVEL << 8) | \ + (TK_RELEASE_SERIAL << 0)) + +/* TK_VERSION_HEX packs fields in wrong order, not suitable for comparing of + * non-final releases. Left for backward compatibility. + */ #define TK_VERSION_HEX ((TK_MAJOR_VERSION << 24) | \ - (TK_MINOR_VERSION << 16) | \ - (TK_RELEASE_SERIAL << 8) | \ - (TK_RELEASE_LEVEL << 0)) + (TK_MINOR_VERSION << 16) | \ + (TK_RELEASE_SERIAL << 8) | \ + (TK_RELEASE_LEVEL << 0)) /* Protect Tk 8.4.13 and older from a deadlock that happens when trying * to load tk after a failed attempt. */ -#if TK_VERSION_HEX < 0x08040e02 +#if TK_HEX_VERSION < 0x0804020e #define TKINTER_PROTECT_LOADTK #define TKINTER_LOADTK_ERRMSG \ - "Calling Tk_Init again after a previous call failed might deadlock" + "Calling Tk_Init again after a previous call failed might deadlock" #endif #endif /* !TKINTER_H */