Skip to content

Commit 56753bc

Browse files
authored
Merge branch 'master' into patch-1
2 parents f9a3f7e + 3c91409 commit 56753bc

File tree

2 files changed

+6
-4
lines changed

2 files changed

+6
-4
lines changed

jupyter_sphinx/execute.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -256,7 +256,8 @@ def write_notebook_output(notebook, output_dir, notebook_name):
256256
resources,
257257
os.path.join(output_dir, notebook_name + ".ipynb"),
258258
)
259-
# Write a script too.
259+
# Write a script too. Note that utf-8 is the de facto
260+
# standard encoding for notebooks.
260261
ext = notebook.metadata.get("language_info", {}).get("file_extension", None)
261262
if ext is None:
262263
ext = ".txt"
@@ -266,7 +267,8 @@ def write_notebook_output(notebook, output_dir, notebook_name):
266267
# location=document.settings.env.docname,
267268
)
268269
contents = "\n\n".join(cell.source for cell in notebook.cells)
269-
with open(os.path.join(output_dir, notebook_name + ext), "w") as f:
270+
with open(os.path.join(output_dir, notebook_name + ext), "w",
271+
encoding = "utf8") as f:
270272
f.write(contents)
271273

272274

tests/test_execute.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,11 +33,11 @@ def doctree(
3333
):
3434
src_dir = tempfile.mkdtemp()
3535
source_trees.append(src_dir)
36-
with open(os.path.join(src_dir, "conf.py"), "w") as f:
36+
with open(os.path.join(src_dir, "conf.py"), "w", encoding = "utf8") as f:
3737
f.write("extensions = ['%s']" % entrypoint)
3838
if config is not None:
3939
f.write("\n" + config)
40-
with open(os.path.join(src_dir, "contents.rst"), "w") as f:
40+
with open(os.path.join(src_dir, "contents.rst"), "w", encoding = "utf8") as f:
4141
f.write(source)
4242
warnings = StringIO()
4343
app = SphinxTestApp(srcdir=path(src_dir), status=StringIO(), warning=warnings)

0 commit comments

Comments
 (0)