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; }