From 0827ac1bdd91b1f006684107b06980a2bbfc9c9c Mon Sep 17 00:00:00 2001 From: Andrew Murray Date: Tue, 1 Oct 2024 07:43:17 +1000 Subject: [PATCH] Do not use repr() --- src/PIL/ImageTk.py | 4 ++-- src/Tk/tkImaging.c | 3 +-- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/PIL/ImageTk.py b/src/PIL/ImageTk.py index bf29fdba54c..18f96702afb 100644 --- a/src/PIL/ImageTk.py +++ b/src/PIL/ImageTk.py @@ -55,14 +55,14 @@ def _pyimagingtkcall( ) -> None: tk = photo.tk try: - tk.call(command, photo, repr(ptr)) + tk.call(command, photo, ptr) except tkinter.TclError: # activate Tkinter hook # may raise an error if it cannot attach to Tkinter from . import _imagingtk _imagingtk.tkinit(tk.interpaddr()) - tk.call(command, photo, repr(ptr)) + tk.call(command, photo, ptr) # -------------------------------------------------------------------- diff --git a/src/Tk/tkImaging.c b/src/Tk/tkImaging.c index a36c3e0bdc4..12a59db3941 100644 --- a/src/Tk/tkImaging.c +++ b/src/Tk/tkImaging.c @@ -61,10 +61,9 @@ ImagingFind(const char *name) { const char *expected = "capsule object \"" IMAGING_MAGIC "\" at 0x"; if (name[0] == '<') { + // Unless PyPy is in use, the PyCapsule is converted to a string representation name++; } else { - // Special case for PyPy, where the string representation of a Capsule - // refers directly to the pointer itself, not to the PyCapsule object. direct_pointer = 1; }