~ihabunek/toot-discuss

This thread contains a patchset. You're looking at the original emails, but you may wish to use the patch review UI. Review patch
1

[PATCH v2] Fix version check in case of an empty string

Details
Message ID
<sby3cfy7u3bcsrejziyjmdxak5qscvai62qirjktdivastdrda@7m6jy3nofoah>
DKIM signature
pass
Download raw message
Patch: +3 -1
Some mastodon implementations (GoToSocial) will return `version: ""`, in
which case checking for the major version won't work.

This is why an extra check has to be added, and default to 0 as the
"major" version.
---
Previous version didn't quote the "0", so ch.isnumeric() failed
 toot/tui/app.py | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/toot/tui/app.py b/toot/tui/app.py
index 8278ef7..1fcfd41 100644
--- a/toot/tui/app.py
+++ b/toot/tui/app.py
@@ -327,8 +327,10 @@ class TUI(urwid.Frame):
                # get the major version number of the server
                # this works for Mastodon and Pleroma version strings
                # Mastodon versions < 4 do not have translation service
                # If the version is missing, assume 0 as a fallback
                # Revisit this logic if Pleroma implements translation
                ch = instance["version"][0]
                version = instance["version"]
                ch = "0" if not version else version[0]
                self.can_translate = int(ch) > 3 if ch.isnumeric() else False

        return self.run_in_thread(_load_instance, done_callback=_done)
-- 
2.44.0

--
Luca
Details
Message ID
<6937dd21-69f6-48ee-bfdb-3f1893d5de1b@app.fastmail.com>
In-Reply-To
<sby3cfy7u3bcsrejziyjmdxak5qscvai62qirjktdivastdrda@7m6jy3nofoah> (view parent)
DKIM signature
pass
Download raw message
Applied, thanks.

-- Ivan
Reply to thread Export thread (mbox)