From e419e6dca0fa4f042770efd4c3e5721e2591d5ae Mon Sep 17 00:00:00 2001 From: Athanasius Date: Sun, 4 Dec 2022 14:56:58 +0000 Subject: [PATCH] update.py: Technically Updater.root can be None, so check this The only current users of the code that blindly uses `self.root` are for the GUI application, but let's add the checks anyway. --- update.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/update.py b/update.py index 4277598f..ce8e4924 100644 --- a/update.py +++ b/update.py @@ -49,7 +49,7 @@ class Updater(object): def shutdown_request(self) -> None: """Receive (Win)Sparkle shutdown request and send it to parent.""" - if not config.shutting_down: + if not config.shutting_down and self.root: self.root.event_generate('<>', when="tail") def use_internal(self) -> bool: @@ -63,14 +63,14 @@ class Updater(object): return False - def __init__(self, tkroot: 'tk.Tk' = None, provider: str = 'internal'): + def __init__(self, tkroot: Optional['tk.Tk'] = None, provider: str = 'internal'): """ Initialise an Updater instance. :param tkroot: reference to the root window of the GUI :param provider: 'internal' or other string if not """ - self.root: 'tk.Tk' = tkroot + self.root: Optional['tk.Tk'] = tkroot self.provider: str = provider self.thread: threading.Thread = None @@ -215,7 +215,7 @@ class Updater(object): """Perform internal update checking & update GUI status if needs be.""" newversion = self.check_appcast() - if newversion: + if newversion and self.root: status = self.root.nametowidget(f'.{appname.lower()}.status') status['text'] = newversion.title + ' is available' self.root.update_idletasks()