Skip to content

Commit

Permalink
Removed redundant try catch
Browse files Browse the repository at this point in the history
  • Loading branch information
radarhere committed Feb 7, 2022
1 parent c6b81d5 commit 3114064
Showing 1 changed file with 18 additions and 20 deletions.
38 changes: 18 additions & 20 deletions src/PIL/ImageTk.py
Expand Up @@ -64,27 +64,25 @@ def _pyimagingtkcall(command, photo, id):
tk.call(command, photo, id)
except tkinter.TclError:
# activate Tkinter hook
# may raise an error if it cannot attach to Tkinter
from . import _imagingtk

try:
from . import _imagingtk

try:
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
# <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)
tk.call(command, photo, id)
except (ImportError, AttributeError, tkinter.TclError):
raise # configuration problem; cannot attach to Tkinter
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
# <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)
tk.call(command, photo, id)


# --------------------------------------------------------------------
Expand Down

0 comments on commit 3114064

Please sign in to comment.