diff --git a/solara/__main__.py b/solara/__main__.py index da34c1b34..347f223e7 100644 --- a/solara/__main__.py +++ b/solara/__main__.py @@ -653,7 +653,7 @@ def markdown(target: typing.Optional[Path] = None): def write_script(name: str, target: typing.Optional[Path]): - code = (HERE / "template" / f"{name}.py").read_text() + code = (HERE / "template" / f"{name}.py").read_text(encoding="utf-8") if target is None: target = Path("sol.py") else: diff --git a/solara/autorouting.py b/solara/autorouting.py index 292037787..c8d6b5ea4 100644 --- a/solara/autorouting.py +++ b/solara/autorouting.py @@ -215,11 +215,9 @@ def get_args(f): solara.Button( icon_name="mdi-pencil", icon=True, href=url, target="_blank", style={"position": "absolute", "top": "0px", "right": "0px"} ) - # solara.Markdown(path.read_text(), unsafe_solara_execute=True) - component(path.read_text(), unsafe_solara_execute=True) + component(path.read_text(encoding="utf-8"), unsafe_solara_execute=True) else: - # content = solara.Markdown(path.read_text(), unsafe_solara_execute=True) - content = component(path.read_text(), unsafe_solara_execute=True) + content = component(path.read_text(encoding="utf-8"), unsafe_solara_execute=True) main = solara.Div( classes=["solara-autorouter-content"], diff --git a/solara/components/style.py b/solara/components/style.py index 9039e7525..60b43ad78 100644 --- a/solara/components/style.py +++ b/solara/components/style.py @@ -52,7 +52,7 @@ async def watch(): try: async for _ in watchfiles.awatch(value): print(value, "changed, reloading css") # noqa - set_css_content_reloaded(cast(Path, value).read_text()) + set_css_content_reloaded(cast(Path, value).read_text(encoding="utf-8")) except RuntimeError: pass # swallow the RuntimeError: Already borrowed errors from watchfiles except Exception: @@ -70,7 +70,7 @@ async def watch(): if css_content_reloaded is not None: css_content = css_content_reloaded else: - css_content = value.read_text() if isinstance(value, Path) else value + css_content = value.read_text(encoding="utf-8") if isinstance(value, Path) else value # del value hash = hashlib.sha256(css_content.encode("utf-8")).hexdigest() # the key is unique for this component + value diff --git a/solara/server/app.py b/solara/server/app.py index 59f37363b..3dc454246 100644 --- a/solara/server/app.py +++ b/solara/server/app.py @@ -229,7 +229,7 @@ def on_file_change(self, name): path = Path(name) if path.suffix == ".vue": logger.info("Vue file changed: %s", name) - template_content = path.read_text() + template_content = path.read_text(encoding="utf-8") for context in list(kernel_context.contexts.values()): with context: for filepath, widget in context.templates.items():