From 17b65e62833b4c3fa4abcd60ba61cbc1eb232fa0 Mon Sep 17 00:00:00 2001 From: JA Viljoen Date: Wed, 13 Oct 2021 10:46:03 +0200 Subject: [PATCH] Explicitly use UTF-8 for text files --- src/groceries/txtdb.py | 4 ++-- tests/conftest.py | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/groceries/txtdb.py b/src/groceries/txtdb.py index 5b79408..021c577 100644 --- a/src/groceries/txtdb.py +++ b/src/groceries/txtdb.py @@ -9,13 +9,13 @@ class TextFile: self._init() def _load(self): - with self._path.open("r") as fh: + with self._path.open("r", encoding="utf-8") as fh: items = todotxt.load(fh) return {i.name: i for i in items} def _write(self, items): - with self._path.open("w") as fh: + with self._path.open("w", encoding="utf-8") as fh: todotxt.dump(items, fh) def _init(self): diff --git a/tests/conftest.py b/tests/conftest.py index 7a36093..1c1c55b 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -23,7 +23,7 @@ def items(): def groceries_file(tmpdir, items): path = Path(tmpdir) / "groceries.txt" - with path.open("w") as fh: + with path.open("w", encoding="utf-8") as fh: todotxt.dump(items, fh) return path -- 2.45.2