From ca923f7bd4eb665909526db7ff8d539d0c90b66a Mon Sep 17 00:00:00 2001 From: Will McGugan Date: Sun, 27 Oct 2024 12:39:15 +0000 Subject: [PATCH] encoding to read demo code --- src/textual/demo/page.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/textual/demo/page.py b/src/textual/demo/page.py index f275c093fb..84d61a147b 100644 --- a/src/textual/demo/page.py +++ b/src/textual/demo/page.py @@ -64,8 +64,9 @@ class PageScreen(Screen): @work(thread=True) def get_code(self, source_file: str) -> str | None: + """Read code from disk, or return `None` on error.""" try: - with open(source_file, "rt") as file_: + with open(source_file, "rt", encoding="utf-8") as file_: return file_.read() except Exception: return None