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.
This commit is contained in:
parent
b69e998ceb
commit
144a4e2b9b
@ -422,19 +422,19 @@ class Mastodon:
|
|||||||
raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified')
|
raise MastodonIllegalArgumentError('Mismatch in base URLs between files and/or specified')
|
||||||
self.api_base_url = try_base_url
|
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
|
# Versioning
|
||||||
if mastodon_version == None:
|
if mastodon_version == None and self.version_check_mode != 'none':
|
||||||
self.retrieve_mastodon_version()
|
self.retrieve_mastodon_version()
|
||||||
else:
|
elif self.version_check_mode != 'none':
|
||||||
try:
|
try:
|
||||||
self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version)
|
self.mastodon_major, self.mastodon_minor, self.mastodon_patch = parse_version_string(mastodon_version)
|
||||||
except:
|
except:
|
||||||
raise MastodonVersionError("Bad version specified")
|
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
|
# Ratelimiting parameter check
|
||||||
if ratelimit_method not in ["throw", "wait", "pace"]:
|
if ratelimit_method not in ["throw", "wait", "pace"]:
|
||||||
raise MastodonIllegalArgumentError("Invalid ratelimit method.")
|
raise MastodonIllegalArgumentError("Invalid ratelimit method.")
|
||||||
|
Loading…
x
Reference in New Issue
Block a user