Skip to content

Commit

Permalink
Fix hasattr for ImageTk.PhotoImage.__del__
Browse files Browse the repository at this point in the history
  • Loading branch information
homm committed Sep 22, 2024
1 parent 87414b3 commit 11bcd5a
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions src/PIL/ImageTk.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,9 +131,10 @@ def __init__(
self.paste(image)

def __del__(self) -> None:
if not hasattr(self, "__photo"):
try:
name = self.__photo.name
except AttributeError:
return
name = self.__photo.name
self.__photo.name = None
try:
self.__photo.tk.call("image", "delete", name)
Expand Down

0 comments on commit 11bcd5a

Please sign in to comment.