From 144a4e2b9bdfd371e651f965f21018dc4dd77fd4 Mon Sep 17 00:00:00 2001 From: fwaggle Date: Sat, 5 Nov 2022 15:01:28 +1100 Subject: Fix version crash when connecting to gotosocial While gotosocial has a PR open to send a Mastodon-compatible version in the `instance` endpoint, whatever it sends is unlikely to be helpful for the purpose of version-gating features in the client library. You can disable version-gating, but it still fails on instantiating due to GtS's version not matching the semver regex. Fix this by moving the version_check_mode above it, and not parsing the version if it's turned off. --- mastodon/Mastodon.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/mastodon/Mastodon.py b/mastodon/Mastodon.py index f6b9f1c..f1a9c5c 100644 --- a/mastodon/Mastodon.py +++ b/mastodon/Mastodon.py @@ -421,20 +421,20 @@ class Mastodon: if not (self.api_base_url is None or try_base_url == self.api_base_url): raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified') self.api_base_url = try_base_url + + if not version_check_mode in ["created", "changed", "none"]: + raise MastodonIllegalArgumentError("Invalid version check method.") + self.version_check_mode = version_check_mode # Versioning - if mastodon_version == None: + if mastodon_version == None and self.version_check_mode != 'none': self.retrieve_mastodon_version() - else: + elif self.version_check_mode != 'none': try: self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version) except: raise MastodonVersionError("Bad version specified") - if not version_check_mode in ["created", "changed", "none"]: - raise MastodonIllegalArgumentError("Invalid version check method.") - self.version_check_mode = version_check_mode - # Ratelimiting parameter check if ratelimit_method not in ["throw", "wait", "pace"]: raise MastodonIllegalArgumentError("Invalid ratelimit method.") -- cgit v1.2.3