aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorfwaggle <[email protected]>2022-11-05 15:01:28 +1100
committerfwaggle <[email protected]>2022-11-05 15:01:28 +1100
commit144a4e2b9bdfd371e651f965f21018dc4dd77fd4 (patch)
tree1ce5bfd62ae882c2360b665205e1752b6ca0e240 /mastodon
parentb69e998cebcf60052a0ccfa76bce073f9817df65 (diff)
downloadmastodon.py-144a4e2b9bdfd371e651f965f21018dc4dd77fd4.tar.gz
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.
Diffstat (limited to 'mastodon')
-rw-r--r--mastodon/Mastodon.py12
1 files 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:
421 if not (self.api_base_url is None or try_base_url == self.api_base_url): 421 if not (self.api_base_url is None or try_base_url == self.api_base_url):
422 raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified') 422 raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified')
423 self.api_base_url = try_base_url 423 self.api_base_url = try_base_url
424
425 if not version_check_mode in ["created", "changed", "none"]:
426 raise MastodonIllegalArgumentError("Invalid version check method.")
427 self.version_check_mode = version_check_mode
424 428
425 # Versioning 429 # Versioning
426 if mastodon_version == None: 430 if mastodon_version == None and self.version_check_mode != 'none':
427 self.retrieve_mastodon_version() 431 self.retrieve_mastodon_version()
428 else: 432 elif self.version_check_mode != 'none':
429 try: 433 try:
430 self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version) 434 self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version)
431 except: 435 except:
432 raise MastodonVersionError("Bad version specified") 436 raise MastodonVersionError("Bad version specified")
433 437
434 if not version_check_mode in ["created", "changed", "none"]:
435 raise MastodonIllegalArgumentError("Invalid version check method.")
436 self.version_check_mode = version_check_mode
437
438 # Ratelimiting parameter check 438 # Ratelimiting parameter check
439 if ratelimit_method not in ["throw", "wait", "pace"]: 439 if ratelimit_method not in ["throw", "wait", "pace"]:
440 raise MastodonIllegalArgumentError("Invalid ratelimit method.") 440 raise MastodonIllegalArgumentError("Invalid ratelimit method.")
Powered by cgit v1.2.3 (git 2.41.0)