Removed redundant try catch

This commit is contained in:
Andrew Murray 2022-02-07 21:06:36 +11:00
parent c6b81d5989
commit 3114064b16

View File

@ -64,27 +64,25 @@ def _pyimagingtkcall(command, photo, id):
tk.call(command, photo, id) tk.call(command, photo, id)
except tkinter.TclError: except tkinter.TclError:
# activate Tkinter hook # activate Tkinter hook
# may raise an error if it cannot attach to Tkinter
from . import _imagingtk
try: try:
from . import _imagingtk if hasattr(tk, "interp"):
# Required for PyPy, which always has CFFI installed
from cffi import FFI
try: ffi = FFI()
if hasattr(tk, "interp"):
# Required for PyPy, which always has CFFI installed
from cffi import FFI
ffi = FFI() # PyPy is using an FFI CDATA element
# (Pdb) self.tk.interp
# PyPy is using an FFI CDATA element # <cdata 'Tcl_Interp *' 0x3061b50>
# (Pdb) self.tk.interp _imagingtk.tkinit(int(ffi.cast("uintptr_t", tk.interp)), 1)
# <cdata 'Tcl_Interp *' 0x3061b50> else:
_imagingtk.tkinit(int(ffi.cast("uintptr_t", tk.interp)), 1) _imagingtk.tkinit(tk.interpaddr(), 1)
else: except AttributeError:
_imagingtk.tkinit(tk.interpaddr(), 1) _imagingtk.tkinit(id(tk), 0)
except AttributeError: tk.call(command, photo, id)
_imagingtk.tkinit(id(tk), 0)
tk.call(command, photo, id)
except (ImportError, AttributeError, tkinter.TclError):
raise # configuration problem; cannot attach to Tkinter
# -------------------------------------------------------------------- # --------------------------------------------------------------------