From 2fc63b3ad4a433f875bde1ebf5d2f8a4c74becd6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Csaba=20Gy=C3=B6rgyi?= Date: Sat, 13 Apr 2024 17:37:00 +0200 Subject: [PATCH] Use Date.no_date() instead of None for Task.date_due In some cases, None was used instead of Date.no_date(), which caused a crash when sorting the task list. This fixes GitHub issue #1068 --- GTG/core/tasks.py | 4 ++-- GTG/gtk/browser/quick_add.py | 2 +- tests/core/test_task.py | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/GTG/core/tasks.py b/GTG/core/tasks.py index 3af19aae83..2c960239a2 100644 --- a/GTG/core/tasks.py +++ b/GTG/core/tasks.py @@ -414,7 +414,7 @@ def is_valid_term(): Return a tuple of (bool, Date) """ if recurring_term is None: - return False, None + return False, Date.no_date() try: # If a start date is already set, @@ -429,7 +429,7 @@ def is_valid_term(): return True, newdate except ValueError: - return False, None + return False, Date.no_date() self._is_recurring = recurring diff --git a/GTG/gtk/browser/quick_add.py b/GTG/gtk/browser/quick_add.py index c8bfa3f93d..d392f03a8f 100644 --- a/GTG/gtk/browser/quick_add.py +++ b/GTG/gtk/browser/quick_add.py @@ -61,7 +61,7 @@ def parse(text: str) -> Dict: 'title': '', 'tags': set(), 'start': None, - 'due': None, + 'due': Date.no_date(), 'recurring': None } diff --git a/tests/core/test_task.py b/tests/core/test_task.py index 650d0e6949..d33fe53aad 100644 --- a/tests/core/test_task.py +++ b/tests/core/test_task.py @@ -214,7 +214,7 @@ def test_due_date(self): # Test changing parent's due (None or nodate) task2.date_due = random_date - task1.date_due = None + task1.date_due = Date.no_date() self.assertEqual(task2.date_due, random_date)