From e9e673882e9a3075e31ded65a02aedd2da79e44c Mon Sep 17 00:00:00 2001 From: Nikos Koukis Date: Mon, 6 Jun 2022 10:00:39 +0100 Subject: [PATCH] Be robust to invalid utf-8 characters in task db Sometimes, there may exist non-printable characters in the taskwarrior `pending.data` file, for example due to an emoji added to the task description but is not yet properly parsed by python. In these cases, we'd want `tasklib` not to crash but rather ignore it and keep parsing the results of the command. --- tasklib/backends.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tasklib/backends.py b/tasklib/backends.py index 0f9bf40..9ec92fb 100644 --- a/tasklib/backends.py +++ b/tasklib/backends.py @@ -149,7 +149,7 @@ def _get_version(self): self._get_task_command() + ['--version'], stdout=subprocess.PIPE, stderr=subprocess.PIPE) - stdout, stderr = [x.decode('utf-8') for x in p.communicate()] + stdout, stderr = [x.decode('utf-8', errors='ignore') for x in p.communicate()] return stdout.strip('\n') def _get_modified_task_fields_as_args(self, task):