Skip to content

Commit

Permalink
Catch AttributeError for BitmapImage.__photo
Browse files Browse the repository at this point in the history
Co-authored-by: Andrew Murray <[email protected]>
  • Loading branch information
homm and radarhere authored Sep 26, 2024
1 parent 11bcd5a commit b9d1768
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 @@ -219,9 +219,10 @@ def __init__(self, image: Image.Image | None = None, **kw: Any) -> None:
self.__photo = tkinter.BitmapImage(data=image.tobitmap(), **kw)

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 b9d1768

Please sign in to comment.