Fix hasattr for ImageTk.PhotoImage.__del__

This commit is contained in:
Aleksandr Karpinskii 2024-09-22 13:39:22 +04:00
parent 87414b3f59
commit 11bcd5aaa9

View File

@ -131,9 +131,10 @@ class PhotoImage:
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)