Remove support for Tk/Tcl <= 8.4, deprecated in 8.2.0

This commit is contained in:
Hugo van Kemenade 2023-04-02 19:32:26 +03:00
parent 59c9d87f8a
commit 070e770469
4 changed files with 22 additions and 72 deletions

View File

@ -12,14 +12,6 @@ Deprecated features
Below are features which are considered deprecated. Where appropriate, Below are features which are considered deprecated. Where appropriate,
a ``DeprecationWarning`` is issued. a ``DeprecationWarning`` is issued.
Tk/Tcl 8.4
~~~~~~~~~~
.. deprecated:: 8.2.0
Support for Tk/Tcl 8.4 is deprecated and will be removed in Pillow 10.0.0 (2023-07-01),
when Tk/Tcl 8.5 will be the minimum supported.
Categories Categories
~~~~~~~~~~ ~~~~~~~~~~
@ -210,6 +202,14 @@ Removed features
Deprecated features are only removed in major releases after an appropriate Deprecated features are only removed in major releases after an appropriate
period of deprecation has passed. period of deprecation has passed.
Tk/Tcl 8.4
~~~~~~~~~~
.. deprecated:: 8.2.0
.. versionremoved:: 10.0.0
Support for Tk/Tcl 8.4 was removed in Pillow 10.0.0 (2023-07-01).
PyQt5 and PySide2 PyQt5 and PySide2
~~~~~~~~~~~~~~~~~ ~~~~~~~~~~~~~~~~~

View File

@ -4,8 +4,6 @@ import sys
import tkinter import tkinter
from tkinter import _tkinter as tk from tkinter import _tkinter as tk
from ._deprecate import deprecate
try: try:
if hasattr(sys, "pypy_find_executable"): if hasattr(sys, "pypy_find_executable"):
TKINTER_LIB = tk.tklib_cffi.__file__ TKINTER_LIB = tk.tklib_cffi.__file__
@ -17,7 +15,3 @@ except AttributeError:
TKINTER_LIB = None TKINTER_LIB = None
tk_version = str(tkinter.TkVersion) tk_version = str(tkinter.TkVersion)
if tk_version == "8.4":
deprecate(
"Support for Tk/Tcl 8.4", 10, action="Please upgrade to Tk/Tcl 8.5 or newer"
)

View File

@ -119,17 +119,7 @@ typedef struct Tk_PhotoImageBlock {
} Tk_PhotoImageBlock; } Tk_PhotoImageBlock;
/* Typedefs derived from function signatures in Tk header */ /* Typedefs derived from function signatures in Tk header */
/* Tk_PhotoPutBlock for Tk <= 8.4 */ typedef int (*Tk_PhotoPutBlock_t)(
typedef void (*Tk_PhotoPutBlock_84_t)(
Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr,
int x,
int y,
int width,
int height,
int compRule);
/* Tk_PhotoPutBlock for Tk >= 8.5 */
typedef int (*Tk_PhotoPutBlock_85_t)(
Tcl_Interp *interp, Tcl_Interp *interp,
Tk_PhotoHandle handle, Tk_PhotoHandle handle,
Tk_PhotoImageBlock *blockPtr, Tk_PhotoImageBlock *blockPtr,
@ -138,8 +128,6 @@ typedef int (*Tk_PhotoPutBlock_85_t)(
int width, int width,
int height, int height,
int compRule); int compRule);
/* Tk_PhotoSetSize for Tk <= 8.4 */
typedef void (*Tk_PhotoSetSize_84_t)(Tk_PhotoHandle handle, int width, int height);
/* Tk_FindPhoto */ /* Tk_FindPhoto */
typedef Tk_PhotoHandle (*Tk_FindPhoto_t)(Tcl_Interp *interp, const char *imageName); typedef Tk_PhotoHandle (*Tk_FindPhoto_t)(Tcl_Interp *interp, const char *imageName);
/* Tk_PhotoGetImage */ /* Tk_PhotoGetImage */

View File

@ -48,14 +48,11 @@
* Global vars for Tcl / Tk functions. We load these symbols from the tkinter * Global vars for Tcl / Tk functions. We load these symbols from the tkinter
* extension module or loaded Tcl / Tk libraries at run-time. * extension module or loaded Tcl / Tk libraries at run-time.
*/ */
static int TK_LT_85 = 0;
static Tcl_CreateCommand_t TCL_CREATE_COMMAND; static Tcl_CreateCommand_t TCL_CREATE_COMMAND;
static Tcl_AppendResult_t TCL_APPEND_RESULT; static Tcl_AppendResult_t TCL_APPEND_RESULT;
static Tk_FindPhoto_t TK_FIND_PHOTO; static Tk_FindPhoto_t TK_FIND_PHOTO;
static Tk_PhotoGetImage_t TK_PHOTO_GET_IMAGE; static Tk_PhotoGetImage_t TK_PHOTO_GET_IMAGE;
static Tk_PhotoPutBlock_84_t TK_PHOTO_PUT_BLOCK_84; static Tk_PhotoPutBlock_t TK_PHOTO_PUT_BLOCK;
static Tk_PhotoSetSize_84_t TK_PHOTO_SET_SIZE_84;
static Tk_PhotoPutBlock_85_t TK_PHOTO_PUT_BLOCK_85;
static Imaging static Imaging
ImagingFind(const char *name) { ImagingFind(const char *name) {
@ -130,26 +127,15 @@ PyImagingPhotoPut(
block.pitch = im->linesize; block.pitch = im->linesize;
block.pixelPtr = (unsigned char *)im->block; block.pixelPtr = (unsigned char *)im->block;
if (TK_LT_85) { /* Tk 8.4 */ TK_PHOTO_PUT_BLOCK(
TK_PHOTO_PUT_BLOCK_84( interp,
photo, &block, 0, 0, block.width, block.height, TK_PHOTO_COMPOSITE_SET); photo,
if (strcmp(im->mode, "RGBA") == 0) { &block,
/* Tk workaround: we need apply ToggleComplexAlphaIfNeeded */ 0,
/* (fixed in Tk 8.5a3) */ 0,
TK_PHOTO_SET_SIZE_84(photo, block.width, block.height); block.width,
} block.height,
} else { TK_PHOTO_COMPOSITE_SET);
/* Tk >=8.5 */
TK_PHOTO_PUT_BLOCK_85(
interp,
photo,
&block,
0,
0,
block.width,
block.height,
TK_PHOTO_COMPOSITE_SET);
}
return TCL_OK; return TCL_OK;
} }
@ -290,16 +276,7 @@ get_tk(HMODULE hMod) {
if ((TK_FIND_PHOTO = (Tk_FindPhoto_t)_dfunc(hMod, "Tk_FindPhoto")) == NULL) { if ((TK_FIND_PHOTO = (Tk_FindPhoto_t)_dfunc(hMod, "Tk_FindPhoto")) == NULL) {
return -1; return -1;
}; };
TK_LT_85 = GetProcAddress(hMod, "Tk_PhotoPutBlock_Panic") == NULL; TK_PHOTO_PUT_BLOCK = (Tk_PhotoPutBlock_t)func;
/* Tk_PhotoPutBlock_Panic defined as of 8.5.0 */
if (TK_LT_85) {
TK_PHOTO_PUT_BLOCK_84 = (Tk_PhotoPutBlock_84_t)func;
return ((TK_PHOTO_SET_SIZE_84 =
(Tk_PhotoSetSize_84_t)_dfunc(hMod, "Tk_PhotoSetSize")) == NULL)
? -1
: 1;
}
TK_PHOTO_PUT_BLOCK_85 = (Tk_PhotoPutBlock_85_t)func;
return 1; return 1;
} }
@ -422,18 +399,9 @@ _func_loader(void *lib) {
if ((TK_FIND_PHOTO = (Tk_FindPhoto_t)_dfunc(lib, "Tk_FindPhoto")) == NULL) { if ((TK_FIND_PHOTO = (Tk_FindPhoto_t)_dfunc(lib, "Tk_FindPhoto")) == NULL) {
return 1; return 1;
} }
/* Tk_PhotoPutBlock_Panic defined as of 8.5.0 */
TK_LT_85 = (dlsym(lib, "Tk_PhotoPutBlock_Panic") == NULL);
if (TK_LT_85) {
return (
((TK_PHOTO_PUT_BLOCK_84 =
(Tk_PhotoPutBlock_84_t)_dfunc(lib, "Tk_PhotoPutBlock")) == NULL) ||
((TK_PHOTO_SET_SIZE_84 =
(Tk_PhotoSetSize_84_t)_dfunc(lib, "Tk_PhotoSetSize")) == NULL));
}
return ( return (
(TK_PHOTO_PUT_BLOCK_85 = (TK_PHOTO_PUT_BLOCK =
(Tk_PhotoPutBlock_85_t)_dfunc(lib, "Tk_PhotoPutBlock")) == NULL); (Tk_PhotoPutBlock_t)_dfunc(lib, "Tk_PhotoPutBlock")) == NULL);
} }
int int