From 6422aaafa9655b91f29bdb399970181ef4a888df Mon Sep 17 00:00:00 2001 From: suve Date: Wed, 29 Mar 2023 12:22:58 +0200 Subject: [PATCH 1/2] Fix crash on startup This commit fixes the program crashing because of an uncaught exception. The bug was triggered by app_settings.last_launched_version being unset - which would always be the case when launching the program for the first time! The bug could also be triggered by manually changing the setting to an invalid value - e.g. by running: $ gsettings set com.github.geigi.cozy last-launched-version 'ayy lmao' --- cozy/ui/widgets/whats_new_window.py | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/cozy/ui/widgets/whats_new_window.py b/cozy/ui/widgets/whats_new_window.py index 1e80d1ef..1a79005b 100644 --- a/cozy/ui/widgets/whats_new_window.py +++ b/cozy/ui/widgets/whats_new_window.py @@ -51,12 +51,16 @@ def __init__(self, **kwargs): def _fill_window(self): self.children = [] - last_launched_version = version.parse(self.app_settings.last_launched_version) - - if type(last_launched_version) is version.LegacyVersion: + try: + last_launched_version = version.parse(self.app_settings.last_launched_version) + except version.InvalidVersion: self._fill_welcome() else: - self._fill_whats_new(last_launched_version) + if type(last_launched_version) is version.LegacyVersion: + self._fill_welcome() + else: + self._fill_whats_new(last_launched_version) + def _fill_welcome(self): from cozy.ui.widgets.welcome import Welcome From 5dd970aafb9f50803344cf1e2c5c91751658a58e Mon Sep 17 00:00:00 2001 From: suve Date: Sun, 28 May 2023 12:09:02 +0200 Subject: [PATCH 2/2] Remove usage of version.LegacyVersion The "packaging" module has deprecated its LegacyVersion identifier back in 2020, finally removing it in 2021. This causes cozy to crash when running against new version of said module, with the following error: > AttributeError: module 'packaging.version' > has no attribute 'LegacyVersion' --- cozy/ui/widgets/whats_new_window.py | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/cozy/ui/widgets/whats_new_window.py b/cozy/ui/widgets/whats_new_window.py index 1a79005b..da3a06f9 100644 --- a/cozy/ui/widgets/whats_new_window.py +++ b/cozy/ui/widgets/whats_new_window.py @@ -56,11 +56,7 @@ def _fill_window(self): except version.InvalidVersion: self._fill_welcome() else: - if type(last_launched_version) is version.LegacyVersion: - self._fill_welcome() - else: - self._fill_whats_new(last_launched_version) - + self._fill_whats_new(last_launched_version) def _fill_welcome(self): from cozy.ui.widgets.welcome import Welcome