From 2ac51ca2a1984a5168269ef2e3d1ce98c1fc3993 Mon Sep 17 00:00:00 2001 From: Shiori Hironaka Date: Fri, 5 Dec 2025 19:41:08 +0900 Subject: [PATCH] Fix UnboundLocalError in streaming API URL parsing --- mastodon/internals.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/mastodon/internals.py b/mastodon/internals.py index bbe3620..8f1dcd1 100644 --- a/mastodon/internals.py +++ b/mastodon/internals.py @@ -386,14 +386,14 @@ def __get_streaming_base(self) -> str: if not streaming_api_url is None and streaming_api_url != self.api_base_url: # This is probably a websockets URL, which is really for the browser, but requests can't handle it # So we do this below to turn it into an HTTPS or HTTP URL - parse = urlparse(instance["urls"]["streaming_api"]) + parse = urlparse(streaming_api_url) if parse.scheme == 'wss': url = "https://" + parse.netloc elif parse.scheme == 'ws': url = "http://" + parse.netloc else: raise MastodonAPIError( - f"Could not parse streaming api location returned from server: {instance['urls']['streaming_api']}." + f"Could not parse streaming api location returned from server: {streaming_api_url}." ) else: url = self.api_base_url