Skip to content

Commit 681f69b

Browse files
fix: on windows, Path.read_text is not utf8 by default
1 parent 1a28643 commit 681f69b

File tree

4 files changed

+6
-8
lines changed

4 files changed

+6
-8
lines changed

solara/__main__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -653,7 +653,7 @@ def markdown(target: typing.Optional[Path] = None):
653653

654654

655655
def write_script(name: str, target: typing.Optional[Path]):
656-
code = (HERE / "template" / f"{name}.py").read_text()
656+
code = (HERE / "template" / f"{name}.py").read_text(encoding="utf-8")
657657
if target is None:
658658
target = Path("sol.py")
659659
else:

solara/autorouting.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -215,11 +215,9 @@ def get_args(f):
215215
solara.Button(
216216
icon_name="mdi-pencil", icon=True, href=url, target="_blank", style={"position": "absolute", "top": "0px", "right": "0px"}
217217
)
218-
# solara.Markdown(path.read_text(), unsafe_solara_execute=True)
219-
component(path.read_text(), unsafe_solara_execute=True)
218+
component(path.read_text(encoding="utf-8"), unsafe_solara_execute=True)
220219
else:
221-
# content = solara.Markdown(path.read_text(), unsafe_solara_execute=True)
222-
content = component(path.read_text(), unsafe_solara_execute=True)
220+
content = component(path.read_text(encoding="utf-8"), unsafe_solara_execute=True)
223221

224222
main = solara.Div(
225223
classes=["solara-autorouter-content"],

solara/components/style.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ async def watch():
5252
try:
5353
async for _ in watchfiles.awatch(value):
5454
print(value, "changed, reloading css") # noqa
55-
set_css_content_reloaded(cast(Path, value).read_text())
55+
set_css_content_reloaded(cast(Path, value).read_text(encoding="utf-8"))
5656
except RuntimeError:
5757
pass # swallow the RuntimeError: Already borrowed errors from watchfiles
5858
except Exception:
@@ -70,7 +70,7 @@ async def watch():
7070
if css_content_reloaded is not None:
7171
css_content = css_content_reloaded
7272
else:
73-
css_content = value.read_text() if isinstance(value, Path) else value
73+
css_content = value.read_text(encoding="utf-8") if isinstance(value, Path) else value
7474
# del value
7575
hash = hashlib.sha256(css_content.encode("utf-8")).hexdigest()
7676
# the key is unique for this component + value

solara/server/app.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ def on_file_change(self, name):
229229
path = Path(name)
230230
if path.suffix == ".vue":
231231
logger.info("Vue file changed: %s", name)
232-
template_content = path.read_text()
232+
template_content = path.read_text(encoding="utf-8")
233233
for context in list(kernel_context.contexts.values()):
234234
with context:
235235
for filepath, widget in context.templates.items():

0 commit comments

Comments
 (0)