Skip to content

Commit

Permalink
encoding to read demo code
Browse files Browse the repository at this point in the history
  • Loading branch information
willmcgugan committed Oct 27, 2024
1 parent 71f8ee3 commit ca923f7
Showing 1 changed file with 2 additions and 1 deletion.
3 changes: 2 additions & 1 deletion src/textual/demo/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ca923f7

Please sign in to comment.