From 729016cf38261f6b8df3df160560d9e332715291 Mon Sep 17 00:00:00 2001 From: Athanasius Date: Fri, 16 Dec 2022 15:35:59 +0000 Subject: [PATCH] companion.py: Fix exception type & initialise a requests_session * Use `Exception` not `BaseException` for `EDMCCAPIFailedRequest.exception`. * Initialise Auth.request_session in its `__init__()`. This *should* fix #1727 - as there'll then be no way for a `Session` to have methods invoked without this set up. --- companion.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/companion.py b/companion.py index 9c1ec02c..cab1640f 100644 --- a/companion.py +++ b/companion.py @@ -601,7 +601,7 @@ class EDMCCAPIFailedRequest(EDMCCAPIReturn): ): super().__init__(query_time=query_time, play_sound=play_sound, auto_update=auto_update) self.message: str = message # User-friendly reason for failure. - self.exception: BaseException = exception # Exception that recipient should raise. + self.exception: Exception = exception # Exception that recipient should raise. class Session(object): @@ -619,7 +619,7 @@ class Session(object): def __init__(self) -> None: self.state = Session.STATE_INIT self.credentials: Optional[Dict[str, Any]] = None - self.requests_session: Optional[requests.Session] = None + self.requests_session: Optional[requests.Session] = requests.Session() self.auth: Optional[Auth] = None self.retrying = False # Avoid infinite loop when successful auth / unsuccessful query self.tk_master: Optional[tk.Tk] = None