Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Removed support for tkinter before Python 1.5.2 #6549

Merged
merged 1 commit into from Aug 30, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
23 changes: 10 additions & 13 deletions src/PIL/ImageTk.py
Expand Up @@ -68,21 +68,18 @@ def _pyimagingtkcall(command, photo, id):
# may raise an error if it cannot attach to Tkinter
from . import _imagingtk

try:
if hasattr(tk, "interp"):
# Required for PyPy, which always has CFFI installed
from cffi import FFI
if hasattr(tk, "interp"):
# Required for PyPy, which always has CFFI installed
from cffi import FFI

ffi = FFI()
ffi = FFI()

# PyPy is using an FFI CDATA element
# (Pdb) self.tk.interp
# <cdata 'Tcl_Interp *' 0x3061b50>
_imagingtk.tkinit(int(ffi.cast("uintptr_t", tk.interp)), 1)
else:
_imagingtk.tkinit(tk.interpaddr(), 1)
except AttributeError:
_imagingtk.tkinit(id(tk), 0)
# PyPy is using an FFI CDATA element
# (Pdb) self.tk.interp
# <cdata 'Tcl_Interp *' 0x3061b50>
_imagingtk.tkinit(int(ffi.cast("uintptr_t", tk.interp)))
else:
_imagingtk.tkinit(tk.interpaddr())
tk.call(command, photo, id)


Expand Down
21 changes: 2 additions & 19 deletions src/_imagingtk.c
Expand Up @@ -23,33 +23,16 @@ TkImaging_Init(Tcl_Interp *interp);
extern int
load_tkinter_funcs(void);

/* copied from _tkinter.c (this isn't as bad as it may seem: for new
versions, we use _tkinter's interpaddr hook instead, and all older
versions use this structure layout) */

typedef struct {
PyObject_HEAD Tcl_Interp *interp;
} TkappObject;

static PyObject *
_tkinit(PyObject *self, PyObject *args) {
Tcl_Interp *interp;

PyObject *arg;
int is_interp;
if (!PyArg_ParseTuple(args, "Oi", &arg, &is_interp)) {
if (!PyArg_ParseTuple(args, "O", &arg)) {
return NULL;
}

if (is_interp) {
interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);
} else {
TkappObject *app;
/* Do it the hard way. This will break if the TkappObject
layout changes */
app = (TkappObject *)PyLong_AsVoidPtr(arg);
interp = app->interp;
}
interp = (Tcl_Interp *)PyLong_AsVoidPtr(arg);

/* This will bomb if interp is invalid... */
TkImaging_Init(interp);
Expand Down